1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
//vodafone call visualisation
//
//Tim Redfern Jan 2012
//
//scale of wall 10.57x2.8m - some parts are obscured
//
//416 x 110 in. ~ 62400x16500 ~ 1029 mpx ~ 2945 MB ram to open
//
//CousinMarriageWorld.svg, nominally 940 × 470 pixels, file size: 1.99 MB
//World_map_(Miller_cylindrical_projection,_blank).svg, nominally 634 × 477 pixels, file size: 1.84 MB
//wikimedia
//
//http://www.vectortemplates.com/vector-world-map.php
//requirements -
//must be able to transform points to a new projection
// maybe not through normal shape library
//must be able to find a random point within the shape
//
//250112 so far so good, can iterate children.
//safest thing is to establish that I can place a point as being inside or outside of a shape
//(are they closed properly!)
//If we can find points in them then we can start the main task:
//connecting parts of the SVG with rows in the spreadsheet
//maybe next first I should look at projections (to keep them happy)
//I have a map with rectangular coords,
//is easy to enough to play with the projection
// public boolean contains(RGeomElem shp)
// public geomerative.RRectangle getBounds()
// --> this is kind of hidden. why? anyway, it should be possible to use it
//another option is to use the OUTLINE of the country (as a purely geometric thing).
import processing.pdf.*;
import geomerative.*;
RShape shp;
//RRectangle cb;
int whichChild,numChildren;
void setup(){
println("vodaviz v0.11");
RG.init(this);
size(800,600,P3D); //,PDF, "testoutput.pdf"); //P3D); //832,220);
smooth();
float m = millis();
shp = RG.loadShape("world_countries_outlines_split.svg");
RG.ignoreStyles();
println("loaded svg in "+((millis()-m)*.001)+" seconds");
numChildren=shp.children.length;
whichChild=0;
}
void draw() {
background(0,0,0);
noFill();
stroke(255);
//strokeWeight(.1);
//RG.shape(shp);
whichChild=(whichChild+1)%numChildren;
//println("child "+whichChild+" of "+numChildren);
//cb=shp.children[whichChild].getBounds();
//plot shapes at points
for (int i=0;i<numChildren;i++) {
String cmd="";
for (int j=0;j<shp.children[i].paths.length;j++) {
//shp.children[i].paths[j].draw();
beginShape();
for (int k=0;k<shp.children[i].paths[j].commands.length;k++) {
RPoint sp=shp.children[i].paths[j].commands[k].startPoint;
//map lat,lng coords
//normalise
float px=(sp.x-26)/736;
float py=(sp.y-110)/358;
float r=getHeight()/2;
float x=r*cos(px*PI*2)*(sin(py)*PI);
float y=r*sin(px*PI*2)*(sin(py)*PI);
float z=r*cos(sin(py)*PI);
//vertex(px*getWidth(),py*getHeight()); //,0); can't use 3D points with PDF
vertex(x+(getWidth()/2),y+(getHeight()/2),z); //z);
if (i==0&&j==0) cmd+=(x+(getWidth()/2))+","+(y+(getHeight()/2))+","+z+" ";
}
endShape();
}
if (cmd!="") println(cmd);
}
noLoop();
//exit();
}
void mousePressed() {
}
|