diff options
Diffstat (limited to 'vodaviz.pde')
| -rw-r--r-- | vodaviz.pde | 76 |
1 files changed, 65 insertions, 11 deletions
diff --git a/vodaviz.pde b/vodaviz.pde index cf7fcf7..7d4ed25 100644 --- a/vodaviz.pde +++ b/vodaviz.pde @@ -79,6 +79,9 @@ The intermediate latitude and longitude is then given by: import processing.pdf.*; import geomerative.*; +float log10 (float x) { + return (log(x) / log(10)); +} class pointNormalise { //take pixel coords and turn into lat/lng radians float xo,xs,yo,ys; @@ -130,6 +133,16 @@ class sphereMap { } } +RPoint screenMapper(RPoint p) { + p.x=((p.x*getWidth())/(PI*2))+(getWidth()/2); + p.y=((p.y*getHeight())/PI)+(getHeight()/2); + return p; +} + +RPoint plerp(RPoint s,RPoint e,float a) { + return new RPoint(lerp(s.x,e.x,a),lerp(s.y,e.y,a)); +} + float GSphereDist(RPoint p1,RPoint p2) { return acos(sin(p1.y)*sin(p2.y)+cos(p1.y)*cos(p2.y)*cos(p1.x-p2.x)); } @@ -156,21 +169,27 @@ calldata calls; country Ireland; +PImage lightmap; + void setup(){ - println("vodaviz v0.11"); + println("vodaviz v0.21"); RG.init(this); //mode="PDF"; - size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600 + if (mode=="PDF") size(832,220,PDF, "vodaviz_test_080212.pdf"); //P3D); //832,220); //nb pdf is 800x600 + else size(832,220); //,PDF, "testoutput.pdf"); //P3D); //832,220); //nb pdf is 800x600 smooth(); float m = millis(); shp = RG.loadShape("countries_named_mercator.svg"); //test_drawing.svg"); //world_countries_outlines_split.svg"); - pnorm = new pointNormalise(26,736,90,390); + pnorm = new pointNormalise(18.279,746.302,129.314,374.293); ptrans = new pointTransform(); - smap = new sphereMap(); + 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"); @@ -178,7 +197,7 @@ void setup(){ data=new csvloader("calls.csv"); calls=new calldata(data.data,shp); - background(0,0,0); + background(255,255,255); noFill(); stroke(255); strokeWeight(.02); @@ -191,6 +210,8 @@ void setup(){ println("40% of LAX to JFK:"+LmJ.y+","+LmJ.x+" radians"); } + + } int i=0; @@ -199,8 +220,10 @@ int j=0; void draw() { //pick a random colour - stroke(random(150)+100,random(150)+100,random(150)+100); + stroke(random(150)+100,random(150)+100,random(150)+100,10); + if (false) //draw globe + { if (true) { //draw countries beginShape(); for (int k=0;k<calls.getcountry(i).outline.paths[0].commands.length;k++) { @@ -210,13 +233,11 @@ void draw() { vertex(dp.x+(getWidth()/2),dp.y+(getHeight()/2)); //,z); //z); } endShape(); - println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points"); + //println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points"); } if (true) { - //pick a random colour - 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); @@ -232,11 +253,44 @@ void draw() { endShape(); } } - println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); + //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); } + + } + else + { + if (true) { //draw countries + beginShape(); + for (int k=0;k<calls.getcountry(i).outline.paths[0].commands.length;k++) { + RPoint sp=calls.getcountry(i).outline.paths[0].commands[k].startPoint; + RPoint dp=screenMapper(pnorm.alise(sp)); + + vertex(dp.x,dp.y); //,z); //z); + } + endShape(); + //println("drawing "+calls.getcountry(i).name+": "+calls.getcountry(i).outline.paths[0].commands.length+" points"); + } + 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); + if (s.x>0&&e.x>0){ //point found + RPoint Sp=screenMapper(pnorm.alise(s)); + RPoint Ep=screenMapper(pnorm.alise(e)); + RPoint Mp=plerp(Sp,Ep,0.75); + beginShape(); + //line(Sp.x+(getWidth()/2),Sp.y+(getHeight()/2),Mp.x+(getWidth()/2),Mp.y+(getHeight()/2)); + //line(Mp.x+(getWidth()/2),Mp.y+(getHeight()/2),Ep.x+(getWidth()/2),Ep.y+(getHeight()/2)); + bezier(Sp.x, Sp.y, Sp.x, Sp.y-((getHeight()-Sp.y)*.1), Ep.x, Ep.y-((getHeight()-Ep.y)*.1), Ep.x, Ep.y); + endShape(); + } + } + //println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); + } + } - i++; + i++; //} if (i==calls.countries.size()-1) { |
