diff options
Diffstat (limited to 'parsecalldata.pde')
| -rw-r--r-- | parsecalldata.pde | 34 |
1 files changed, 16 insertions, 18 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;j<brp.y-tlp.y;j+=step) { RPoint pn=new RPoint(tl.x+(i*xstep),tl.y+(j*ystep)); if(outline.contains(pn)) { - float bn=brightness(lightmap.get((int)tlp.x+i,(int)tlp.y+j))+1;//gives a 0.4% weighting to blank pixels + float bn=brightness(lightmap.get((int)tlp.x+i,(int)tlp.y+j))+.01;//gives a 0.039% weighting to blank pixels points.add(new weightedpixel(pn,bn)); btotal +=bn; if (bn>bmax) 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; + } } } |
