From 845583c9feabc291d146095996bfd2f04f2887a5 Mon Sep 17 00:00:00 2001 From: "git@eclectronics.org" Date: Mon, 20 Feb 2012 00:55:07 +0000 Subject: sampling work --- parsecalldata.pde | 34 ++++++++++++++++------------------ vodaviz.pde | 4 ++-- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/parsecalldata.pde b/parsecalldata.pde index ecc1a77..e3e409e 100644 --- a/parsecalldata.pde +++ b/parsecalldata.pde @@ -61,14 +61,13 @@ class country{ if (searching==0) return np; else return new RPoint(0,0); } - RPoint getcentre(){ - RPoint tl=outline.getTopLeft(); - RPoint br=outline.getBottomRight(); - return new RPoint((tl.x+br.x)*0.5,(tl.y+br.y)*0.5); -} + RPoint getcentre(){ + RPoint tl=outline.getTopLeft(); + RPoint br=outline.getBottomRight(); + return new RPoint((tl.x+br.x)*0.5,(tl.y+br.y)*0.5); + } } - class weightedpixel { float bright; RPoint pt; @@ -77,9 +76,6 @@ class weightedpixel { pt=_p; bright=_b; } - RPoint randompt(float r) { - return new RPoint(pt.x+random(r),pt.y+random(r)); - } } class bitmapcountry extends country { @@ -101,8 +97,8 @@ class bitmapcountry extends country { bitmapcountry(String n,float c,float m,float al,float u,float as,float ne,RShape shp) { super(n,c,m,al,u,as,ne,shp); } - void analyse(float _xo,float _xs,float _yo,float _ys) { - int step=2; //speedup + void analyse(float _xo,float _xs,float _yo,float _ys,int step) { + //int step=2; //speedup xo=_xo; xs=_xs; yo=_yo; @@ -122,7 +118,7 @@ class bitmapcountry extends country { for (int j=0;jbmax) bmax=bn; @@ -178,6 +174,7 @@ class calldata { XMLInOut xmlInOut; PApplet pApplet; boolean loaded; + int step; //coarseness of bitmap analysis country getcountry(int w) { return countries.get(w); @@ -211,14 +208,15 @@ class calldata { } } println("loaded "+countries.size()+" countries, "+pts+" data points in "+((millis()-start)*.001)+"secs"); - loaded=true; - } + loaded=true; +} - calldata(String[][] data,RShape shp,String filename,PApplet _pApplet) { + calldata(String[][] data,RShape shp,String filename,int _step,PApplet _pApplet) { start=millis(); boolean parsedata=true; pApplet=_pApplet; loaded=false; + step=_step; /* try { //to deserialise File file = new File("countries.dat"); @@ -273,7 +271,7 @@ class calldata { for (int i=0; i < countries.size(); i++) { //if (DEBUG) countries.get(i).printOut(); countries.get(i).getavgs(); - countries.get(i).analyse(18.279,746.302,109,374.293); + countries.get(i).analyse(18.279,746.302,109,374.293,step); proxml.XMLElement country = new proxml.XMLElement("country"); country.addAttribute("name",countries.get(i).name); country.addAttribute("calls",countries.get(i).calls); @@ -297,8 +295,8 @@ class calldata { } xmlInOut.saveElement(xmlcountries,filename); println("generated "+filename+": "+countries.size()+" countries in "+((millis()-start)*.001)+"secs"); - loaded=true; - } + loaded=true; + } } } diff --git a/vodaviz.pde b/vodaviz.pde index e7ac204..70f6626 100644 --- a/vodaviz.pde +++ b/vodaviz.pde @@ -254,9 +254,9 @@ void setup(){ RG.ignoreStyles(); println("loaded svg in "+((millis()-m)*.001)+" seconds"); Ireland=new bitmapcountry("Ireland",0,0,0,0,0,0,shp.children[0]); - Ireland.analyse(18.279,746.302,109,374.293); + Ireland.analyse(18.279,746.302,109,374.293,5); data=new csvloader("calls.csv"); - calls=new calldata(data.data,shp,"countries5.xml",this); + calls=new calldata(data.data,shp,"countries5.xml",5,this); background(255,255,255); noFill(); -- cgit v1.2.3