summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2012-02-12 14:53:03 +0000
committerTim Redfern <tim@eclectronics.org>2012-02-12 14:53:03 +0000
commitdd522964ed23aad978f691531dfd6c384ac86260 (patch)
treeff928f95b1f533f621cbcd482639d4e3fca94c78
parente22a28b930d02ac7b30fd4866bef2ec2d22a062d (diff)
good bitmap reading
-rw-r--r--parsecalldata.pde7
-rw-r--r--vodaviz.pde24
2 files changed, 17 insertions, 14 deletions
diff --git a/parsecalldata.pde b/parsecalldata.pde
index 5870e6d..ba6e46f 100644
--- a/parsecalldata.pde
+++ b/parsecalldata.pde
@@ -68,6 +68,7 @@ class bitmapcountry extends country {
super(n,c,m,shp);
}
void analyse(float _xo,float _xs,float _yo,float _ys) {
+ int step=5; //speedup
xo=_xo;
xs=_xs;
yo=_yo;
@@ -82,12 +83,12 @@ class bitmapcountry extends country {
float bmin=255;
float bmax=0;
println("searching "+tl.x+","+tl.y+" -> "+(tl.x+(pixstep*(brp.x-tlp.x)))+","+(tl.y+(pixstep*(brp.y-tlp.y))));
- for (int i=0;i<brp.x-tlp.x;i++) {
- for (int j=0;j<brp.y-tlp.y;j++) {
+ for (int i=0;i<brp.x-tlp.x;i+=step) {
+ for (int j=0;j<brp.y-tlp.y;j+=step) {
RPoint pn=new RPoint(tl.x+(i*pixstep),tl.y+(j*pixstep));
if(outline.contains(pn)) {
float bn=brightness(lightmap.get((int)brp.x+i,(int)brp.y+j));
- points.add(new weightedpixel(normalise(pn),bn));
+ points.add(new weightedpixel(pn,bn));
totalbright +=bn;
if (bn>bmax) bmax=bn;
if (bn<bmin) bmin=bn;
diff --git a/vodaviz.pde b/vodaviz.pde
index 7d4ed25..3590b93 100644
--- a/vodaviz.pde
+++ b/vodaviz.pde
@@ -167,7 +167,7 @@ String mode;
csvloader data;
calldata calls;
-country Ireland;
+bitmapcountry Ireland;
PImage lightmap;
@@ -189,11 +189,12 @@ void setup(){
smap = new sphereMap();
lightmap=loadImage("earthlights2_dmsp_big.jpg");
- image(lightmap,0,0,getWidth(),getHeight());
+
RG.ignoreStyles();
println("loaded svg in "+((millis()-m)*.001)+" seconds");
- Ireland=new country("Ireland",0,0,shp.children[0]);
+ Ireland=new bitmapcountry("Ireland",0,0,shp.children[0]);
+ Ireland.analyse(18.279,746.302,129.314,374.293);
data=new csvloader("calls.csv");
calls=new calldata(data.data,shp);
@@ -218,11 +219,12 @@ int i=0;
int j=0;
void draw() {
-
+ //if (i==0) image(lightmap,0,0,getWidth(),getHeight());
+
//pick a random colour
- stroke(random(150)+100,random(150)+100,random(150)+100,10);
+ stroke(random(150)+10,random(150)+10,random(150)+10);
- if (false) //draw globe
+ if (true) //draw globe
{
if (true) { //draw countries
beginShape();
@@ -239,8 +241,8 @@ void draw() {
if (true) {
for (int j=0;j<calls.countries.get(i).calls*.001;j++) {
- RPoint s=calls.countries.get(i).getpoint(100);
- RPoint e=Ireland.getpoint(100);
+ RPoint s=calls.countries.get(i).getpoint();
+ RPoint e=Ireland.getpoint();
if (s.x>0&&e.x>0){ //point found
RPoint sp=ptrans.form(pnorm.alise(s));
RPoint ep=ptrans.form(pnorm.alise(e));
@@ -257,7 +259,7 @@ void draw() {
}
}
- else
+ else //draw 2D
{
if (true) { //draw countries
beginShape();
@@ -272,8 +274,8 @@ void draw() {
}
if (true) { //draw lines
for (int j=0;j<log10(calls.countries.get(i).calls)*100;j++) {
- RPoint s=calls.countries.get(i).getpoint(100);
- RPoint e=Ireland.getpoint(100);
+ RPoint s=calls.countries.get(i).getpoint();
+ RPoint e=Ireland.getpoint();
if (s.x>0&&e.x>0){ //point found
RPoint Sp=screenMapper(pnorm.alise(s));
RPoint Ep=screenMapper(pnorm.alise(e));