From dd419cfe1232a86583f013bd5fc6b18153bc13f5 Mon Sep 17 00:00:00 2001 From: "git@eclectronics.org" Date: Wed, 18 Jul 2012 01:39:48 +0100 Subject: fixed mirroring --- data/tim-openpaths.kml | 156 +++++++++++++++++++++++++++++++++++++++++++++++++ gpsviewer.pde | 37 +++++------- 2 files changed, 172 insertions(+), 21 deletions(-) diff --git a/data/tim-openpaths.kml b/data/tim-openpaths.kml index 91b65ac..4e40d67 100644 --- a/data/tim-openpaths.kml +++ b/data/tim-openpaths.kml @@ -19,6 +19,32 @@ -6.25055074692 53.3443069458 20.6979007721 2012-07-17T15:30:08 -6.25054168701 53.3442764282 20.8298339844 + 2012-07-17T16:10:40 + -6.25052213669 53.3442802429 22.034198761 + 2012-07-17T18:42:08 + -6.26801204681 53.3547554016 20.6610202789 + 2012-07-17T18:52:48 + -6.27976989746 53.3499298096 26.7142848969 + 2012-07-17T19:01:20 + -6.30523586273 53.3501625061 25.9673271179 + 2012-07-17T19:07:44 + -6.33194732666 53.3739013672 25.9673271179 + 2012-07-17T19:14:08 + -6.32204961777 53.343788147 25.9673271179 + 2012-07-17T19:20:32 + -6.30197620392 53.3562393188 25.9673271179 + 2012-07-17T19:29:04 + -6.31624221802 53.3664207458 25.9673271179 + 2012-07-17T19:39:44 + -6.28307294846 53.3515167236 25.9673271179 + 2012-07-17T19:44:00 + -6.26699638367 53.3522415161 24.3768482208 + 2012-07-17T23:55:44 + -6.2671585083 53.3520851135 25.2789287567 + 2012-07-17T23:57:52 + -6.2671918869 53.3521385193 25.2789287567 + 2012-07-17T23:57:52 + -6.26708841324 53.352142334 24.1845855713 @@ -71,5 +97,135 @@ -6.25054168701,53.3442764282,20.8298339844 + + + + 2012-07-17T16:10:40 + + + + -6.25052213669,53.3442802429,22.034198761 + + + + + + 2012-07-17T18:42:08 + + + + -6.26801204681,53.3547554016,20.6610202789 + + + + + + 2012-07-17T18:52:48 + + + + -6.27976989746,53.3499298096,26.7142848969 + + + + + + 2012-07-17T19:01:20 + + + + -6.30523586273,53.3501625061,25.9673271179 + + + + + + 2012-07-17T19:07:44 + + + + -6.33194732666,53.3739013672,25.9673271179 + + + + + + 2012-07-17T19:14:08 + + + + -6.32204961777,53.343788147,25.9673271179 + + + + + + 2012-07-17T19:20:32 + + + + -6.30197620392,53.3562393188,25.9673271179 + + + + + + 2012-07-17T19:29:04 + + + + -6.31624221802,53.3664207458,25.9673271179 + + + + + + 2012-07-17T19:39:44 + + + + -6.28307294846,53.3515167236,25.9673271179 + + + + + + 2012-07-17T19:44:00 + + + + -6.26699638367,53.3522415161,24.3768482208 + + + + + + 2012-07-17T23:55:44 + + + + -6.2671585083,53.3520851135,25.2789287567 + + + + + + 2012-07-17T23:57:52 + + + + -6.2671918869,53.3521385193,25.2789287567 + + + + + + 2012-07-17T23:57:52 + + + + -6.26708841324,53.352142334,24.1845855713 + + \ No newline at end of file diff --git a/gpsviewer.pde b/gpsviewer.pde index da614b2..715c79f 100644 --- a/gpsviewer.pde +++ b/gpsviewer.pde @@ -13,7 +13,7 @@ class p3d { p3d max=new p3d(-1000,-1000,-1000); p3d min=new p3d(1000,1000,1000); -float xo,yo,sc; +float xOffset,yOffset,spanDegrees; void addPoint(String[] coord) { p3d p; @@ -31,7 +31,7 @@ void addPoint(String[] coord) { } void setup() { - size(200, 200); + size(512,512); kml = new XMLElement(this, "tim-openpaths.kml").getChild("Document"); //kml = new XMLElement(this, "everytrip-demo.kml").getChild("Document"); int num = kml.getChildCount(); @@ -53,38 +53,33 @@ void setup() { //work out offsets if (max.x-min.x>max.y-min.y) { //scale to X - xo=0; - yo=(height/2)-((height*((max.y-min.y)/(max.x-min.x))*0.5)); - println("ratio: "+str((max.y-min.y)/(max.x-min.x))); + xOffset=0; + yOffset=(height/2)-((height*((max.y-min.y)/(max.x-min.x))*0.5)); // } else { //scale to Y - xo=(width/2)-((width*((max.x-min.x)/(max.y-min.y))*0.5)); + xOffset=(width/2)-((width*((max.x-min.x)/(max.y-min.y))*0.5)); println("ratio: "+str((max.x-min.x)/(max.y-min.y))); - yo=0; + yOffset=0; } - size(512,512); + background(0); stroke(255); } void draw() { - println(str(min.x)+","+str(min.y)+" to "+str(max.x)+","+str(max.y)); - println("offset: "+str(xo)+","+str(yo)); - sc=max(max.x-min.x,max.y-min.y); - if (sc==0.0) println("no movement!"); + spanDegrees=max(max.x-min.x,max.y-min.y); + if (spanDegrees==0.0) println("no movement!"); else { - float psc; //pixels per degree - if (max.x-min.x>max.y-min.y) psc=width/sc; //maximum span of latitude/longitude - else psc=height/sc; - //println("scale: "+str(sc)+" :"+str(width/sc)+" pixels/degree"); + float pixelsPerDegree; + if (max.x-min.x>max.y-min.y) pixelsPerDegree=width/spanDegrees; //maximum span of latitude/longitude + else pixelsPerDegree=height/spanDegrees; for (int i=0;i