[Mapbender-commits] r6612 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jul 22 10:48:37 EDT 2010


Author: verenadiewald
Date: 2010-07-22 14:48:37 +0000 (Thu, 22 Jul 2010)
New Revision: 6612

Modified:
   trunk/mapbender/lib/point.js
Log:
new function transform

Modified: trunk/mapbender/lib/point.js
===================================================================
--- trunk/mapbender/lib/point.js	2010-07-22 14:47:58 UTC (rev 6611)
+++ trunk/mapbender/lib/point.js	2010-07-22 14:48:37 UTC (rev 6612)
@@ -140,3 +140,25 @@
 		return "POINT Z (" + this.x + " " + this.y + " " + this.z + ")";
 	}
 }
+
+/**
+ * transforms {@link Point} coords from source crs to dest crs
+ * @param {String} source crs
+ * @param {String} dest crs
+ * @return a new {@link Point} transformed into dest crs
+ */
+Mapbender.Point.prototype.transform = function(source, dest, callback){
+	var source = new Proj4js.Proj(source);
+	var dest = new Proj4js.Proj(dest);
+	var that = this;
+	
+	var intervalId = setInterval(function() {
+		if(source.readyToUse && dest.readyToUse) {
+			clearInterval(intervalId);
+			var p = new Proj4js.Point(that.x, that.y);
+			p = Proj4js.transform(source, dest, p);
+			p = new Mapbender.Point(p.x, p.y);
+			callback(p);
+        } 
+	}, 200);
+};



More information about the Mapbender_commits mailing list