From be791a55506c1986606c3ab6c3694484f50a2188 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Tue, 7 Feb 2012 16:42:11 +0000 Subject: still wonky paths --- data/countries_named_mercator.svg | 219 ++++++++++++++++++++++++++++++++++---- other/thoughts | 4 +- parsecalldata.pde | 9 +- vodaviz.pde | 151 +++++++++++++++----------- 4 files changed, 294 insertions(+), 89 deletions(-) diff --git a/data/countries_named_mercator.svg b/data/countries_named_mercator.svg index cbe8991..e55a9ca 100644 --- a/data/countries_named_mercator.svg +++ b/data/countries_named_mercator.svg @@ -26,15 +26,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1440" - inkscape:window-height="823" + inkscape:window-width="1152" + inkscape:window-height="835" id="namedview3653" showgrid="false" - inkscape:zoom="1.808408" + inkscape:zoom="1.9592741" inkscape:cx="458.178" inkscape:cy="316.1525" inkscape:window-x="0" - inkscape:window-y="24" + inkscape:window-y="0" inkscape:window-maximized="1" inkscape:current-layer="svg2" /> @@ -1761,13 +1905,7 @@ points=" 426.498,195.396 426.738,195.635 426.498,195.875 426.498,196.115 426.738,196.355 426.979,196.596 427.218,196.835 426.979,196.835 426.979,197.076 426.738,197.076 426.979,197.076 426.979,197.315 426.258,197.556 426.019,197.315 425.777,197.315 425.538,197.556 426.019,197.556 426.258,197.796 426.019,198.036 425.538,198.036 425.777,198.276 425.538,198.276 425.538,198.516 425.777,198.516 425.538,198.756 425.777,198.756 425.538,198.756 425.298,198.756 424.818,199.236 424.578,199.236 424.578,199.476 424.818,199.716 423.857,199.476 423.618,199.716 422.897,199.716 422.418,199.716 422.178,199.956 421.698,199.956 421.698,200.196 421.458,199.956 420.738,199.956 420.019,199.956 419.298,199.716 418.338,199.716 417.378,199.476 417.139,199.476 416.897,199.236 416.658,198.996 416.658,198.756 416.897,198.756 415.938,198.996 415.698,198.756 415.218,198.996 414.979,198.996 414.738,198.996 414.258,199.476 413.777,199.236 413.538,199.236 413.298,199.236 413.298,198.996 413.058,198.996 412.818,198.996 412.578,199.236 412.338,199.236 411.857,198.996 411.857,198.756 411.378,198.756 411.378,198.516 411.378,198.276 411.378,198.036 411.618,198.036 411.378,197.796 411.618,197.796 411.857,197.796 411.857,197.556 411.857,197.796 412.098,197.796 412.338,197.796 412.338,198.036 412.578,198.036 412.578,198.276 412.818,198.276 413.298,198.036 413.058,197.796 413.298,197.556 413.298,197.796 413.538,197.796 414.019,197.796 414.258,198.036 414.498,198.036 414.738,198.036 415.218,198.036 415.218,197.796 415.458,197.796 415.698,197.556 416.178,197.556 416.897,197.556 416.658,197.556 416.897,197.315 416.897,197.556 417.378,197.556 418.098,197.556 418.098,197.796 418.578,198.036 418.578,197.796 418.578,197.556 418.578,197.315 418.338,197.315 418.578,197.076 417.857,196.596 418.338,196.355 419.298,196.115 419.298,195.875 419.298,195.635 419.538,195.635 420.019,195.635 420.258,195.396 420.019,195.396 420.258,195.155 420.738,195.396 420.498,195.635 421.218,195.635 421.458,195.396 421.938,195.635 422.178,195.155 422.418,195.155 422.658,194.675 422.897,194.675 422.897,194.916 423.378,194.675 424.338,194.916 424.578,195.155 424.818,195.155 425.538,195.396 425.777,195.155 426.019,195.155 426.258,195.396 426.498,195.396 " id="_AUSTRIA" style="fill:none;stroke:#6e7072;stroke-width:0.23999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:3.8499999" - inkscape:label="#polyline104" /> + \ No newline at end of file diff --git a/other/thoughts b/other/thoughts index c08cda8..225efca 100644 --- a/other/thoughts +++ b/other/thoughts @@ -45,7 +45,9 @@ no calls anyway -for now, removing ANDORRA ANTIGUA ANGUILA - +0&&ep.x>0){ - RPoint Sp=shpmap.map(sp.x,sp.y); - RPoint Ep=shpmap.map(ep.x,ep.y); + if (true) { //draw countries + beginShape(); + for (int k=0;k0&&e.x>0){ //point found + RPoint sp=ptrans.form(pnorm.alise(s)); + RPoint ep=ptrans.form(pnorm.alise(e)); + RPoint Sp=smap.per(sp,4); + RPoint Ep=smap.per(ep,4); + RPoint Mp=smap.per(GCircFract(sp,ep,0.8),4.1); + 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)); + endShape(); + } } - //} - j=j+1; - if (j>(calls.countries.get(i).calls*.01)){ - i++; - stroke(random(200)+50, random(200)+50,random(200)+50); - println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); - j=0; - } + println("plotting "+calls.countries.get(i).name+": "+calls.countries.get(i).calls+" calls"); + } + + + i++; //} if (i==calls.countries.size()-1) { - println("finished"); - noLoop(); + println("finished"); + noLoop(); + if (mode=="PDF") exit(); } - //if (mode=="PDF") exit(); } void mousePressed() { -- cgit v1.2.3 From e515983033bbd6f2619962c31e34b825a1068309 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Wed, 8 Feb 2012 21:26:36 +0000 Subject: drawing 2d --- data/countries_named_mercator.svg | 162 +++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 4 deletions(-) diff --git a/data/countries_named_mercator.svg b/data/countries_named_mercator.svg index e55a9ca..8a3bed5 100644 --- a/data/countries_named_mercator.svg +++ b/data/countries_named_mercator.svg @@ -26,15 +26,15 @@ guidetolerance="10" inkscape:pageopacity="0" inkscape:pageshadow="2" - inkscape:window-width="1152" - inkscape:window-height="835" + inkscape:window-width="1440" + inkscape:window-height="823" id="namedview3653" showgrid="false" inkscape:zoom="1.9592741" inkscape:cx="458.178" inkscape:cy="316.1525" inkscape:window-x="0" - inkscape:window-y="0" + inkscape:window-y="24" inkscape:window-maximized="1" inkscape:current-layer="svg2" /> @@ -2036,4 +2124,70 @@ points=" 377.778,274.125 377.778,274.365 378.258,274.365 378.258,274.125 378.498,274.125 378.738,274.365 378.498,274.605 378.738,274.605 378.738,274.845 378.498,274.845 378.498,275.085 378.738,275.085 378.978,275.325 378.978,275.085 379.218,275.085 379.218,274.845 379.698,274.605 379.938,274.605 380.178,275.085 380.418,275.085 380.658,274.845 380.658,275.085 380.898,275.085 381.138,275.565 381.138,275.806 381.378,275.806 381.618,276.045 381.858,276.286 382.098,276.286 382.098,276.045 382.098,276.286 382.338,276.286 382.338,276.525 382.578,276.525 382.578,276.286 383.058,276.045 383.778,275.806 384.738,275.806 384.738,276.045 384.978,275.806 384.978,276.045 385.218,276.286 385.458,276.286 385.698,276.766 385.938,276.766 385.938,277.005 385.938,277.246 385.698,277.486 385.938,277.726 386.178,278.206 386.418,279.406 386.178,279.406 386.178,279.646 385.938,279.646 385.698,279.886 385.698,280.126 385.218,281.566 384.978,281.806 384.738,282.286 384.978,282.526 384.738,282.526 384.978,283.247 385.218,284.207 385.218,284.446 385.458,284.446 385.458,284.687 385.698,284.687 385.938,285.167 385.698,285.167 385.938,285.646 385.458,285.887 385.458,285.646 385.698,285.646 385.458,285.646 384.978,285.646 384.978,285.167 384.738,285.407 384.498,285.646 384.738,285.646 384.498,285.646 383.778,285.646 383.778,285.407 383.778,285.646 383.538,285.646 383.298,285.407 383.538,285.407 383.778,285.407 383.778,285.167 383.538,285.167 383.778,285.407 383.538,285.407 383.298,285.407 383.058,285.407 382.338,285.407 382.098,285.407 381.858,285.407 381.618,285.407 381.618,285.646 382.098,285.646 382.818,285.407 383.298,285.407 382.578,285.646 381.378,285.646 381.138,285.646 380.898,285.646 380.418,285.407 380.418,285.646 380.178,285.646 380.418,285.646 380.658,285.646 381.138,285.646 380.178,285.887 379.938,285.646 379.218,285.887 378.258,286.367 377.058,286.607 376.818,286.847 376.578,287.087 376.098,287.327 375.858,287.327 375.858,287.087 375.858,286.127 375.858,285.887 376.098,285.407 376.338,285.407 376.098,285.167 376.338,284.687 376.098,284.687 376.098,284.207 375.618,283.966 375.618,284.207 375.378,283.966 375.378,283.727 375.138,283.727 375.378,283.486 375.138,283.247 374.658,283.247 374.418,283.247 374.178,283.247 374.178,283.006 373.938,283.006 373.698,282.766 373.938,282.766 374.178,282.286 374.418,281.566 374.178,281.326 373.938,280.846 373.938,280.606 374.178,280.606 374.418,280.606 374.898,279.646 375.138,279.646 374.898,279.646 374.898,279.406 374.658,279.406 374.418,279.166 374.418,278.926 374.418,278.686 375.138,278.686 375.138,278.926 375.378,278.926 375.378,278.686 375.378,278.926 375.618,278.926 375.618,278.446 375.378,278.206 375.138,278.206 374.898,278.206 375.138,277.726 375.378,277.486 375.138,277.246 375.138,277.005 375.138,276.766 374.898,277.005 374.898,276.766 374.658,276.766 374.658,276.045 374.658,275.806 374.658,275.565 374.898,275.325 375.138,275.325 375.618,274.845 375.858,274.845 375.858,274.605 376.098,274.605 376.098,274.845 376.338,274.845 376.338,275.085 377.058,275.325 377.058,275.085 377.058,274.845 377.538,274.845 377.778,274.845 377.778,274.365 377.778,274.125 " id="COTE_DIVOIRE" style="fill:none;stroke:#6e7072;stroke-width:0.23999999;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:3.8499999" - inkscape:label="#polyline796" /> \ No newline at end of file + inkscape:label="#polyline796" /> \ No newline at end of file -- cgit v1.2.3 From c7284a5e4f7a1ed2846344d7b221ad74db8d0334 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 9 Feb 2012 17:41:22 +0000 Subject: loading bitmap into country --- parsecalldata.pde | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++----- vodaviz.pde | 76 ++++++++++++++++++++++++++++++++++++++------- 2 files changed, 150 insertions(+), 19 deletions(-) diff --git a/parsecalldata.pde b/parsecalldata.pde index f346381..f82c0e3 100644 --- a/parsecalldata.pde +++ b/parsecalldata.pde @@ -1,10 +1,13 @@ //BT IRELAND MTM,Destination CID Name,VIA,Calls,MINS,ALOC,% User,ASR,NER 02 -boolean DEBUG=false; +boolean DEBUG=true; class country { String name; float calls,mins; RShape outline; + country() { + super(); + } country(String n,float c,float m,RShape shp){ name=n; calls=c; @@ -26,7 +29,7 @@ class country { while (searching>0&&searching0)); + //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); } @@ -36,9 +39,82 @@ class country { } } +class weightedpixel { + float bright; + RPoint pt; + float index; //index weighted from 0-1 + weightedpixel(RPoint _p,float _b) { + pt=_p; + bright=_b; + } +} + +class bitmapcountry extends country { + //examines a bitmap + //builds a table of population desnsity + + //look at it from the POV of how its gonna be used + //getpoints(int num) should be able to return an array of points to draw from + //should be dithered + //has to distribute the points around the brightest points first + //distribute in proportion to their brightness - weighted + + //table of pixels: if within shape: + //sample brightness, keep running total and store normalised weighted index for quick searching + + float xo,xs,yo,ys; + Vector points = new Vector(); + bitmapcountry(String n,float c,float m,RShape shp) { + super(n,c,m,shp); + } + void analyse(float _xo,float _xs,float _yo,float _ys) { + xo=_xo; + xs=_xs; + yo=_yo; + ys=_ys; + //scan country outline by pixel + RPoint tl=outline.getTopLeft(); + RPoint br=outline.getBottomRight(); + RPoint tlp=normpix(tl); + RPoint brp=normpix(br); + float pixstep=(br.x-tl.x)/lightmap.width; + float totalbright=0; + for (int i=0;i countries = new Vector(); + Vector countries = new Vector(); HashMap outlines = new HashMap(); calldata(String[][] data,RShape shp) { @@ -50,7 +126,7 @@ class calldata { //detect number of countries int num=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))])); + countries.add(new bitmapcountry(data[0][1],0.0,0.0,shp.children[outlines.get(data[0][1].substring(0, 3))])); } for (int i=0; i < data.length; i++) { @@ -60,15 +136,16 @@ class calldata { else { 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))])); + countries.add(new bitmapcountry(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))])); } } } - if (DEBUG) { + for (int i=0; i < countries.size(); i++) { - countries.get(i).printOut(); + //if (DEBUG) countries.get(i).printOut(); + countries.get(i).analyse(18.279,746.302,129.314,374.293); } - } + } country getcountry(int w) { return countries.get(w); 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;k0&&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) { -- cgit v1.2.3 From e22a28b930d02ac7b30fd4866bef2ec2d22a062d Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Sat, 11 Feb 2012 13:18:09 +0000 Subject: bitmap lines --- parsecalldata.pde | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/parsecalldata.pde b/parsecalldata.pde index f82c0e3..5870e6d 100644 --- a/parsecalldata.pde +++ b/parsecalldata.pde @@ -77,8 +77,11 @@ class bitmapcountry extends country { RPoint br=outline.getBottomRight(); RPoint tlp=normpix(tl); RPoint brp=normpix(br); - float pixstep=(br.x-tl.x)/lightmap.width; + float pixstep=xs/lightmap.width; float totalbright=0; + 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;ibmax) bmax=bn; + if (bn Date: Sun, 12 Feb 2012 14:53:03 +0000 Subject: good bitmap reading --- parsecalldata.pde | 7 ++++--- vodaviz.pde | 24 +++++++++++++----------- 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;ibmax) bmax=bn; if (bn0&&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;j0&&e.x>0){ //point found RPoint Sp=screenMapper(pnorm.alise(s)); RPoint Ep=screenMapper(pnorm.alise(e)); -- cgit v1.2.3