Index: applications/editors/josm/plugins/agpifoj/build.xml
===================================================================
--- applications/editors/josm/plugins/agpifoj/build.xml	(revision 16290)
+++ applications/editors/josm/plugins/agpifoj/build.xml	(revision 16294)
@@ -34,5 +34,5 @@
                 <attribute name="Plugin-Early" value="false"/>
                 <attribute name="Plugin-Link" value="http://wiki.openstreetmap.org/index.php/JOSM/Plugins/AgPifoJ"/>
-                <attribute name="Plugin-Mainversion" value="1722"/>
+                <attribute name="Plugin-Mainversion" value="1725"/>
                 <attribute name="Plugin-Version" value="${version.entry.commit.revision}"/>
             </manifest>
Index: applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/AgpifojLayer.java
===================================================================
--- applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/AgpifojLayer.java	(revision 16290)
+++ applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/AgpifojLayer.java	(revision 16294)
@@ -29,4 +29,5 @@
 import org.openstreetmap.josm.Main;
 import org.openstreetmap.josm.actions.RenameLayerAction;
+import org.openstreetmap.josm.data.coor.CachedLatLon;
 import org.openstreetmap.josm.data.coor.EastNorth;
 import org.openstreetmap.josm.data.coor.LatLon;
@@ -53,5 +54,5 @@
 
     private int currentPhoto = -1;
-    
+
     // These are used by the auto-guess function to store the result,
     // so when the dialig is re-opened the users modifications don't
@@ -68,6 +69,5 @@
         Date time;
         LatLon exifCoor;
-        LatLon coor;
-        EastNorth pos;
+        CachedLatLon pos;
         /** Speed in kilometer per second */
         Double speed;
@@ -75,4 +75,8 @@
         Double elevation;
 
+        public void setCoor(LatLon latlon)
+        {
+            pos = new CachedLatLon(latlon);
+        }
         public int compareTo(ImageEntry image) {
             if (time != null && image.time != null) {
@@ -362,5 +366,5 @@
     public void visitBoundingBox(BoundingXYVisitor v) {
         for (ImageEntry e : data)
-            v.visit(e.pos);
+            v.visit(e.pos.getEastNorth());
     }
 
@@ -411,10 +415,8 @@
             // Store values
 
-            e.coor = new LatLon(lat, lon);
-            e.exifCoor = e.coor;
-            e.pos = Main.proj.latlon2eastNorth(e.coor);
+            e.setCoor(new LatLon(lat, lon));
+            e.exifCoor = e.pos;
 
         } catch (Exception p) {
-            e.coor = null;
             e.pos = null;
         }
Index: applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java
===================================================================
--- applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java	(revision 16290)
+++ applications/editors/josm/plugins/agpifoj/src/org/openstreetmap/josm/plugins/agpifoj/CorrelateGpxWithImages.java	(revision 16294)
@@ -765,5 +765,4 @@
                 // Reset previous position
                 for(ImageEntry x : autoImgs) {
-                    x.coor = null;
                     x.pos = null;
                 }
@@ -893,5 +892,4 @@
                 if (e.time != null) {
                     // Reset previous position
-                    e.coor = null;
                     e.pos = null;
                     dateImgLst.add(e);
@@ -908,5 +906,5 @@
         } else {
             for (ImageEntry e : yLayer.data) {
-                if (e.time != null && e.coor == null) {
+                if (e.time != null && e.pos == null) {
                     dateImgLst.add(e);
                 }
@@ -999,7 +997,6 @@
             while(i >= 0 && (dateImgLst.get(i).time.getTime()/1000) <= curDateWp
                         && (dateImgLst.get(i).time.getTime()/1000) >= (curDateWp - interval)) {
-                if(dateImgLst.get(i).coor == null) {
-                    dateImgLst.get(i).pos = curWp.eastNorth;
-                    dateImgLst.get(i).coor = Main.proj.eastNorth2latlon(dateImgLst.get(i).pos);
+                if(dateImgLst.get(i).pos == null) {
+                    dateImgLst.get(i).setCoor(curWp.getCoor());
                     dateImgLst.get(i).speed = speed;
                     dateImgLst.get(i).elevation = curElevation;
@@ -1016,16 +1013,13 @@
         while(i >= 0 && (imgDate = dateImgLst.get(i).time.getTime()/1000) >= prevDateWp) {
 
-            if(dateImgLst.get(i).coor == null) {
+            if(dateImgLst.get(i).pos == null) {
                 // The values of timeDiff are between 0 and 1, it is not seconds but a dimensionless
                 // variable
                 double timeDiff = (double)(imgDate - prevDateWp) / interval;
-                dateImgLst.get(i).pos = new EastNorth(
-                        interpolate(prevWp.eastNorth.east(),  curWp.eastNorth.east(),  timeDiff),
-                        interpolate(prevWp.eastNorth.north(), curWp.eastNorth.north(), timeDiff));
-                dateImgLst.get(i).coor = Main.proj.eastNorth2latlon(dateImgLst.get(i).pos);
+                dateImgLst.get(i).setCoor(prevWp.getCoor().interpolate(curWp.getCoor(), timeDiff));
                 dateImgLst.get(i).speed = speed;
 
                 if (curElevation != null && prevElevation != null)
-                    dateImgLst.get(i).elevation = interpolate(prevElevation, curElevation, timeDiff);
+                    dateImgLst.get(i).elevation = prevElevation + (curElevation - prevElevation) * timeDiff;
 
                 ret++;
@@ -1034,8 +1028,4 @@
         }
         return ret;
-    }
-
-    private double interpolate(double val1, double val2, double time) {
-        return val1 + (val2 - val1) * time;
     }
 
@@ -1168,8 +1158,8 @@
      * Formula and earth radius from : http://en.wikipedia.org/wiki/Great-circle_distance */
     public double getDistance(WayPoint p1, WayPoint p2) {
-        double p1Lat = p1.latlon.lat() * Math.PI / 180;
-        double p1Lon = p1.latlon.lon() * Math.PI / 180;
-        double p2Lat = p2.latlon.lat() * Math.PI / 180;
-        double p2Lon = p2.latlon.lon() * Math.PI / 180;
+        double p1Lat = p1.getCoor().lat() * Math.PI / 180;
+        double p1Lon = p1.getCoor().lon() * Math.PI / 180;
+        double p2Lat = p2.getCoor().lat() * Math.PI / 180;
+        double p2Lon = p2.getCoor().lon() * Math.PI / 180;
         double ret = Math.atan2(Math.sqrt(Math.pow(Math.cos(p2Lat) * Math.sin(p2Lon - p1Lon), 2)
                                           + Math.pow(Math.cos(p1Lat) * Math.sin(p2Lat)
