Skip to content

Commit

Permalink
Fixing up bugs after recent changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Shea authored and Dave Shea committed Nov 23, 2009
1 parent 254bbff commit 23bb1a4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 34 deletions.
7 changes: 0 additions & 7 deletions Elevation.pde
Expand Up @@ -235,13 +235,6 @@ void draw() {
// move the tracks around based on user input
translate(scene.offsetX, scene.offsetY, scene.offsetZ);

// translate the tracks to the center of the canvas
// translate(
// 0 - (findDifference(scene.minX, scene.maxX) / 2),
// 0 - (findDifference(scene.minY, scene.maxY) / 2),
// 0 - (findDifference(scene.minZ, scene.maxZ) / 2)
// );

// draw each track
for (int i = 0; i < numTracks; i++) {
tracklist[i].render();
Expand Down
9 changes: 0 additions & 9 deletions fileParsing.pde
Expand Up @@ -73,9 +73,6 @@ Tracks parseXML(String file) {
Google, Microsoft, Yahoo all use and one day I may just get Elevation talking to them. Best to be on
the same system. Longitude is fine as-is, but latitude needs to be run through a formula adapted from
the maths on http://en.wikipedia.org/wiki/Mercator_projection
*/
int degreeLength = 111000;
Expand Down Expand Up @@ -180,12 +177,6 @@ ArrayList listFileNames(String dir) {

// find the absolute difference between two numbers,
float findDifference(float n1, float n2) {
// if (n1 - n2 < 0) {
// return abs(n1) + abs(n2);
// }
// else {
// return abs(n1 - n2);
// }
return abs(n1 - n2) / 2;
}

Expand Down
35 changes: 19 additions & 16 deletions tracks.pde
Expand Up @@ -129,35 +129,38 @@ class Tracks {


void getDimensions() {
// loop through all points and find the ranges
for (int i = 1; i < pointCount; i++) {
scene.minX = checkMe(scene.minX, X[i], "min");
scene.maxX = checkMe(scene.maxX, X[i], "max");
scene.offsetX = 0 - (scene.minX + findDifference(scene.minX, scene.maxX));

scene.minY = checkMe(scene.minY, Y[i], "min");
scene.maxY = checkMe(scene.maxY, Y[i], "max");
scene.offsetY = 0 - (scene.minY + findDifference(scene.minY, scene.maxY));

scene.minZ = checkMe(scene.minZ, Z[i], "min");
scene.maxZ = checkMe(scene.maxZ, Z[i], "max");
scene.offsetZ = 0 - (scene.minZ + findDifference(scene.minZ, scene.maxZ));

scene.minSpeed = checkMe(scene.minSpeed, speed[i], "min");
scene.maxSpeed = checkMe(scene.maxSpeed, speed[i], "max");

// math to compensate for latitude distortion
// adapted from http://msdn.microsoft.com/en-us/library/bb259689.aspx
scene.currentWidth = findDifference(scene.maxZ, scene.minZ) * cos(scene.averageLat * PI/180);
scene.currentHeight = findDifference(scene.maxX, scene.minX) * cos(scene.averageLat * PI/180);

// find out which direction is the largest, then adjust drawingScale to fit the scene
if ((scene.maxX - scene.minX) > (scene.maxY - scene.minY)) {
scene.drawingScale = scene.canvasWidth / (scene.maxX - scene.minX) / 2;
} else {
scene.drawingScale = scene.canvasHeight / (scene.maxY - scene.minY) / 2;
}

};

// move the scene center point to 0, 0
scene.offsetX = 0 - (scene.minX + findDifference(scene.minX, scene.maxX));
scene.offsetY = 0 - (scene.minY + findDifference(scene.minY, scene.maxY));
scene.offsetZ = 0 - (scene.minZ + findDifference(scene.minZ, scene.maxZ));

// math to compensate for latitude distortion
// adapted from http://msdn.microsoft.com/en-us/library/bb259689.aspx
scene.currentWidth = findDifference(scene.minZ, scene.maxZ) * 2 * cos(scene.averageLat * PI/180);
scene.currentHeight = findDifference(scene.minX, scene.maxX) * 2 * cos(scene.averageLat * PI/180);

// find out which direction is the largest, then adjust drawingScale to fit the scene
if ((scene.maxX - scene.minX) > (scene.maxY - scene.minY)) {
scene.drawingScale = scene.canvasWidth / (scene.maxX - scene.minX) / 2;
} else {
scene.drawingScale = scene.canvasHeight / (scene.maxY - scene.minY) / 2;
}

};


Expand Down
4 changes: 2 additions & 2 deletions ui.pde
Expand Up @@ -64,8 +64,8 @@ class Scene {
};
};
// kind of goofy that I need this, but I've committed to converting my internal coordinates to meters
// so now I need this function to keep track of the average latitude of the scene. The value it produces
// is used in a calculation that compensates for Mercator distortion. See Tracks.getDimensions
// so now I need this function to keep track of the average raw latitude of the scene. The value it
// produces is used in a calculation that compensates for Mercator distortion. See Tracks.getDimensions
void averageParallel(float av) {
averageLatCount++;
// find average of preceding values + new one
Expand Down

0 comments on commit 23bb1a4

Please sign in to comment.