http://www.geoplaner.com/
a very useful site. My code below:
/*put the text file generated by convertGps.pde
into the data file for this sketch. Visualises elevations (heights) on my journey to Goldsmiths.
Ignore the x data in this version which was adapted from my earlier program
Dare 2012 */
float[] as, lon, lat;
float x, y;
int index;
ArrayList thatXPos = new ArrayList(); //array for X
ArrayList thatYPos = new ArrayList(); //array for Y
//y in this case is elevation data
float lonMax, lonMin, latMax, latMin; //to be our min and max values
void setup() {
// noLoop();
size(250, 220);
as = float(loadStrings("cleanfile.txt")); /*create this file in 'convertGPS.pde */
background(0);
}
void draw() {
// background(255);
println(mouseX);
///you might have to adjust start and ends but this seems to work
for (int i =0;i<as.length-2;i+=2) { //all the longitude every 3rd
thatXPos.add(as[i]);
}
///you might have to adjust start and ends but this seems to work
for (int i =1;i<as.length-1;i+=2) { //all the Y latitude
thatYPos.add(as[i]);
}
int len = thatXPos.size();
int len2 = thatYPos.size();
Float[] fa = new Float[len];
Float[] fa2 = new Float[len2];
float[] xPosCount = new float[len];
float[] yPosCount = new float[len2];
thatXPos.toArray(fa);
thatYPos.toArray(fa2);
for (int i =0;i< len; i++) {
xPosCount[i] = fa[i];
}
for (int i =0;i< len2; i++) {
yPosCount[i] = fa2[i];
}
lonMax =max(xPosCount);
lonMin =min(xPosCount);
latMax =max(yPosCount);
latMin =min(yPosCount);
/* fill(255);
text(lonMax, 10, 30);
text(lonMin, 10, 50);
text(latMax, 180, 30);
text(latMin, 180, 50);
*/
// for (int i = 0; i < len; i++) {
if (index < len) {
x =xPosCount[index];
y =yPosCount[index];
//println("lat: "+xPosCount[i] + "lon: "+yPosCount[i]*-1);
//use the minimums and maximums to calculate map()
float x1= map(x, lonMin, lonMax, 50, width-50);
float y2= map(y, latMin, latMax, 50, height-50);
fill(255, 0, 0, 240);
stroke(255, 0, 0);
line(index*5, height, index*5, height-y2);
// point( x1, y2);
// println("lat: "+x1 + "lon: "+y2);
}
index = index +1;
}
void mousePressed() {
save("elevation.gif");
}
//end
No comments:
Post a Comment