Creating lines using an array - help please!
in
Programming Questions
•
6 months ago
I'm using data that I collected using the AntiMap log application for iPhone. It collects data using Latitude, Longitude, Compass, Speed, Distance, Time. I built an array to store all of this data, but I need to plot the points and draw lines connecting the points.
This is an example of the data:
This is the code that I have so far:
Can someone please help me?
This is an example of the data:
40.544951,-75.674205,310,83.18,5.37,8096,
40.544951,-75.674205,310,83.18,5.37,8129,
40.544951,-75.674205,310,83.18,5.37,8163,
40.544951,-75.674205,310,83.18,5.37,8196,
40.544999,-75.673914,310,84.24,5.40,8228,
40.544999,-75.673914,310,84.24,5.40,8262,
40.544999,-75.673914,310,84.24,5.40,8295,
40.544999,-75.673914,310,84.24,5.40,8328,
40.544999,-75.673914,310,84.24,5.40,8362,
40.544999,-75.673914,310,84.24,5.40,8395,
40.544999,-75.673914,310,84.24,5.40,8429,
40.544999,-75.673914,310,84.24,5.40,8462,
40.544999,-75.673914,310,84.24,5.40,8495,
40.544999,-75.673914,310,84.24,5.40,8529,
40.544999,-75.673914,310,84.24,5.40,8562,
This is the code that I have so far:
-
- String[] lines;
- float max1, min1, max2, min2;
- float a, b;
- float[] x = new float[100000];
- float[] y = new float[100000];
- void draw() {
- background(255);
- stroke(0);
- }
- void setup() {
- size( 1000, 1000);
- background( 200) ;
- lines = loadStrings("090213_0950_29.csv");
- // println(lines.length);
- // this gets the values from the files & calculates the min & max
- for (int i=0;i<lines.length;i++) {
- a = float(split(lines[i], ',')[0]);
- b = (float(split(lines[i], ',')[1]))*-1;
- if (i==0) {
- max1=min1=a;
- max2=min2=b;
- }
- if ( a<min1 ) min1=a;
- if ( a>max1) max1=a;
- if ( b<min2 ) min2=b;
- if ( b>max2) max2=b;
- // println( a + " " + b );
- //smooth();
- // point( float(split(lines[i],',')[0])*100, (float(split(lines[i],',')[1]))*-1 );
- }
- // println( ">>"+max1+" " + min1 + " >>"+max2+" " +min2);
- float newA, newB;
- for (int i=0;i<lines.length;i++) {
- a = float(split(lines[i], ',')[0]);
- b = (float(split(lines[i], ',')[1]))*-1;
- newA = (map( a, min1, max1, 0, 100))*4;
- newB = map( b, min2, max2, 0, 10000);
- x[i] = newA;
- y[i] = newB;
- // draw newA and newB
- }
- }
- //println( ">>"+max1+" " + min1 + " >>"+max2+" " +min2);
1