[Mapbender-commits] r4274 - in trunk/mapbender: http/javascripts http/php http/print lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jul 1 11:05:08 EDT 2009


Author: christoph
Date: 2009-07-01 11:05:08 -0400 (Wed, 01 Jul 2009)
New Revision: 4274

Added:
   trunk/mapbender/lib/extent.js
Modified:
   trunk/mapbender/http/javascripts/map.js
   trunk/mapbender/http/javascripts/map.php
   trunk/mapbender/http/javascripts/map_obj.js
   trunk/mapbender/http/javascripts/mod_changeEPSG.php
   trunk/mapbender/http/javascripts/mod_dynamicOverview.php
   trunk/mapbender/http/javascripts/mod_export_image.php
   trunk/mapbender/http/javascripts/mod_print1.php
   trunk/mapbender/http/javascripts/mod_scaleHint.php
   trunk/mapbender/http/javascripts/mod_scaleText.php
   trunk/mapbender/http/javascripts/mod_selectMapsize.php
   trunk/mapbender/http/javascripts/mod_setBBOX1.php
   trunk/mapbender/http/php/mod_changeEPSG_dynamic.php
   trunk/mapbender/http/print/mod_printPDF.php
   trunk/mapbender/lib/backwards_compatibility_to_2.6.js
   trunk/mapbender/lib/point.js
Log:
Extent is now Mapbender.Extent

Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/map.js	2009-07-01 15:05:08 UTC (rev 4274)
@@ -7,94 +7,6 @@
 var mb_end_y = 0;
 
 /**
- * @class extent
- * @param {float} minx
- * @param {float} miny
- * @param {float} maxx
- * @param {float} maxy
- * @return the extent as object
- * @type Object
- */
-function Extent(minx,miny,maxx,maxy) {
-	var that = this;
-
-	var setMin = function (min) {
-		that.min = min;
-		that.minx = min.x;
-		that.miny = min.y;
-	};
-	var setMax = function (max) {
-		that.max = max;
-		that.maxx = max.x;
-		that.maxy = max.y;
-	};
-	
-	var setExtent = function (extent) {
-		that.extent = extent;
-		that.extentx = extent.x;
-		that.extenty = extent.y;
-	};
-	
-	var setCenter = function (center) {
-		that.center = center;
-		that.centerx = center.x;
-		that.centery = center.y;
-	};
-	
-	/**
-	 * Allows to set the center (one param) or the extent (two params)
-	 * 
-	 * @param {Point} min or center
-	 * @param {Point} max [obsolete if first is center]
-	 */
-	this.set = function (min, max) {
-		// only one parameter (center)
-		if (typeof max === "undefined") {
-			var newLowerLeft = min.minus(this.extent.dividedBy(2));
-			var newUpperRight = min.plus(this.extent.dividedBy(2));
-			setMin(newLowerLeft);
-			setMax(newUpperRight);
-			setCenter(min);
-		}
-		// two parameters (lower left and upper right ( = extent))
-		else {
-			setMin(min);
-			setMax(max);
-			setExtent(max.minus(min));
-			setCenter((min.plus(max)).dividedBy(2));
-		}
-	};
-
-	this.toString = function () {
-		return this.min.x + "," + this.min.y + "," + this.max.x + "," + this.max.y;
-	};
-	
-	var isPoint = function (param) {
-		if (typeof param === "object" && param.constructor === Point) {
-			return true;
-		}
-		return false;
-	};
-	
-	if (isPoint(minx) && isPoint(miny) && 
-		typeof maxx === "undefined" && 
-		typeof maxy === "undefined") {
-
-		// input is "point, point"
-		this.set(minx, miny);
-	}
-	else {
-		// input is "coordinate, coordinate, coordinate, coordinate"
-		// deprecated
-		this.set(
-			new Point(parseFloat(minx), parseFloat(miny)),
-			new Point(parseFloat(maxx), parseFloat(maxy))
-		);
-	}
-	return this;
-}
-
-/**
  * @deprecated
  */
 function mb_execloadWmsSubFunctions(){
@@ -431,7 +343,7 @@
 function mb_repaint(frameName,minx,miny,maxx,maxy){
 	new Mb_warning("The function mb_repaint is deprecated.");
 	var ind = getMapObjIndexByName(frameName);
-	mb_mapObj[ind].extent = new Extent(minx, miny, maxx, maxy);
+	mb_mapObj[ind].extent = new Mapbender.Extent(minx, miny, maxx, maxy);
 	setMapRequest(frameName);
 }
 
@@ -453,6 +365,6 @@
 function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
   new Mb_warning("The function mb_calculateExtent is deprecated.");
   var map = getMapObjByName(frameName);
-  var extent = new Extent(minx,miny,maxx,maxy);
+  var extent = new Mapbender.Extent(minx,miny,maxx,maxy);
   map.calculateExtent(extent);
 }

Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/map.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -120,6 +120,7 @@
 						"point.js",
 						"style.js",
 						"button.js",
+						"extent.js",
 						"backwards_compatibility_to_2.6.js"
 );
 

Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/map_obj.js	2009-07-01 15:05:08 UTC (rev 4274)
@@ -273,7 +273,7 @@
 			bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
 		}
 	}
-	var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+	var wmsExtent = new Mapbender.Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
 	this.calculateExtent(wmsExtent);
 
 	this.mapURL = [];
@@ -302,7 +302,7 @@
 	 */
 	this.getExtentInfos = function(){
 		var c = this.extent.toString().split(",");
-		var ext = new Extent(c[0], c[1], c[2], c[3]);
+		var ext = new Mapbender.Extent(c[0], c[1], c[2], c[3]);
 		return ext;
 	};
 	
@@ -421,7 +421,7 @@
 					var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
 					var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
 	
-					var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+					var wmsExtent = new Mapbender.Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
 					var newExtent = this.calculateExtent(wmsExtent);
 					this.repaint(newExtent.min, newExtent.max);
 					break;
@@ -769,7 +769,7 @@
 	
 	this.repaint = function(min, max){
 		if (typeof min !== "undefined" && typeof max !== "undefined") {
-			this.extent = new Extent(min, max);
+			this.extent = new Mapbender.Extent(min, max);
 		}
 		this.setMapRequest();
 	};

Modified: trunk/mapbender/http/javascripts/mod_changeEPSG.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -80,7 +80,7 @@
 					}
 					else{
 						map.epsg = newExtent[i].newSrs;
-						map.extent = new Extent(
+						map.extent = new Mapbender.Extent(
 							parseFloat(newExtent[i].minx), 
 							parseFloat(newExtent[i].miny),
 							parseFloat(newExtent[i].maxx), 
@@ -92,7 +92,7 @@
 				else {
 					var map = Mapbender.modules[newExtent[i].frameName];
 					map.epsg = newExtent[i].newSrs;
-					map.extent = new Extent(
+					map.extent = new Mapbender.Extent(
 						parseFloat(newExtent[i].minx),
 						parseFloat(newExtent[i].miny), 
 						parseFloat(newExtent[i].maxx),

Modified: trunk/mapbender/http/javascripts/mod_dynamicOverview.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_dynamicOverview.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_dynamicOverview.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -76,7 +76,7 @@
 		var miny = parseFloat(arrayCoords[1]);
 		var maxx = parseFloat(arrayCoords[2]);
 		var maxy = parseFloat(arrayCoords[3]);
-		var newExtent = new Extent(minx, miny, maxx, maxy)
+		var newExtent = new Mapbender.Extent(minx, miny, maxx, maxy)
 		map0.calculateExtent(newExtent);
 	}
 

Modified: trunk/mapbender/http/javascripts/mod_export_image.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_export_image.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_export_image.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -158,7 +158,7 @@
 		window.opener.window.frames[mod_print1_target].document.getElementById("maps").style.width = document.form1.map_width.value;
 		window.opener.window.frames[mod_print1_target].document.getElementById("maps").style.height = document.form1.map_height.value;
       
-		window.opener.mb_mapObj[ind].extent = new window.opener.Extent(
+		window.opener.mb_mapObj[ind].extent = new window.opener.Mapbender.Extent(
 			coord[0],
 			pos[1],
 			pos[0],

Modified: trunk/mapbender/http/javascripts/mod_print1.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_print1.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_print1.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -157,7 +157,7 @@
 		window.opener.window.frames[mod_print1_target].document.getElementById("maps").style.width = document.form1.map_width.value;
 		window.opener.window.frames[mod_print1_target].document.getElementById("maps").style.height = document.form1.map_height.value;
       
-		window.opener.mb_mapObj[ind].extent = new window.opener.Extent(
+		window.opener.mb_mapObj[ind].extent = new window.opener.Mapbender.Extent(
 			coord[0],
 			pos[1],
 			pos[0],

Modified: trunk/mapbender/http/javascripts/mod_scaleHint.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_scaleHint.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_scaleHint.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -48,7 +48,7 @@
 			var miny = parseFloat(y) -  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * newScale);
 			var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * newScale);
 			var maxy = parseFloat(y) +  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * newScale);
-			mb_mapObj[ind].extent = new Extent(
+			mb_mapObj[ind].extent = new Mapbender.Extent(
 				minx,
 				miny,
 				maxx,

Modified: trunk/mapbender/http/javascripts/mod_scaleText.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_scaleText.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_scaleText.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -39,7 +39,7 @@
 	var miny = parseFloat(y) -  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale.value);
 	var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale.value);
 	var maxy = parseFloat(y) +  (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale.value);     
-	mb_mapObj[ind].extent = new Extent(
+	mb_mapObj[ind].extent = new Mapbender.Extent(
 		minx,
 		miny,
 		maxx,

Modified: trunk/mapbender/http/javascripts/mod_selectMapsize.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_selectMapsize.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_selectMapsize.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -28,7 +28,7 @@
 	var h = parseInt(p[1]);
 	var pos = makeClickPos2RealWorldPos(mod_selectMapsize_target,w,h);
 	var coords = mb_mapObj[ind].extent.toString().split(",");
-	mb_mapObj[ind].extent = new Extent(
+	mb_mapObj[ind].extent = new Mapbender.Extent(
 		coords[0],
 		pos[1],
 		pos[0],

Modified: trunk/mapbender/http/javascripts/mod_setBBOX1.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_setBBOX1.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/javascripts/mod_setBBOX1.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -31,7 +31,7 @@
 			var mapObj = getMapObjByName(my_target);
 			if (mapObj) {
 				var coord = myBBOX.split(","); 
-				var newExtent = new Extent(parseFloat(coord[0]),parseFloat(coord[1]),parseFloat(coord[2]),parseFloat(coord[3]));
+				var newExtent = new Mapbender.Extent(parseFloat(coord[0]),parseFloat(coord[1]),parseFloat(coord[2]),parseFloat(coord[3]));
 
 				// if the restrictedExtent attribute exists, it has been 
 				// configured by the user in the element variable.

Modified: trunk/mapbender/http/php/mod_changeEPSG_dynamic.php
===================================================================
--- trunk/mapbender/http/php/mod_changeEPSG_dynamic.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/php/mod_changeEPSG_dynamic.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -188,7 +188,7 @@
 				}
 				else{
 					parent.mb_mapObj[ind].epsg = temp[1];
-					parent.mb_mapObj[ind].extent = new parent.Extent(
+					parent.mb_mapObj[ind].extent = new parent.Mapbender.Extent(
 						parseFloat(temp[2]),
 						parseFloat(temp[3]),
 						parseFloat(temp[4]),
@@ -200,7 +200,7 @@
 			if(temp[0] != myTarget){
 				var ind = parent.getMapObjIndexByName(temp[0]);
 				parent.mb_mapObj[ind].epsg = temp[1];
-				parent.mb_mapObj[ind].extent = new parent.Extent(
+				parent.mb_mapObj[ind].extent = new parent.Mapbender.Extent(
 					parseFloat(temp[2]),
 					parseFloat(temp[3]),
 					parseFloat(temp[4]),

Modified: trunk/mapbender/http/print/mod_printPDF.php
===================================================================
--- trunk/mapbender/http/print/mod_printPDF.php	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/http/print/mod_printPDF.php	2009-07-01 15:05:08 UTC (rev 4274)
@@ -185,7 +185,7 @@
 			}
 			var pos = pt.makeClickPos2RealWorldPos(target, map_width , map_height);
 			var prevscale= pt.mb_getScale(target);
-			pt.mb_mapObj[ind].extent = new pt.Extent(
+			pt.mb_mapObj[ind].extent = new pt.Mapbender.Extent(
 				coord[0],
 				pos[1],
 				pos[0],
@@ -234,7 +234,7 @@
 			var centerY = parseFloat(coord[1]) + (parseFloat(coord[3]) - parseFloat(coord[1]))/2
 			
 			var pos = pt.makeClickPos2RealWorldPos(target, map_width , map_height);
-			pt.mb_mapObj[ind].extent = new pt.Extent(
+			pt.mb_mapObj[ind].extent = new pt.Mapbender.Extent(
 				coord[0],
 				pos[1],
 				pos[0],

Modified: trunk/mapbender/lib/backwards_compatibility_to_2.6.js
===================================================================
--- trunk/mapbender/lib/backwards_compatibility_to_2.6.js	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/lib/backwards_compatibility_to_2.6.js	2009-07-01 15:05:08 UTC (rev 4274)
@@ -12,8 +12,8 @@
 var Mb_warning = Mapbender.Warning;
 var Mb_exception = Mapbender.Exception;
 
+var Extent = Mapbender.Extent;
 
-
 /**
  * A wrapper for an AJAX request via GET 
  * 

Added: trunk/mapbender/lib/extent.js
===================================================================
--- trunk/mapbender/lib/extent.js	                        (rev 0)
+++ trunk/mapbender/lib/extent.js	2009-07-01 15:05:08 UTC (rev 4274)
@@ -0,0 +1,120 @@
+/**
+ * Package: Extent
+ * 
+ * Description:
+ * An extent is also known as a bounding box. 
+ * 
+ * Files:
+ *  - lib/extent.js
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License 
+ * and Simplified BSD license.  
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+/**
+ * Constructor: Extent
+ * 
+ * Parameters (coordinates):
+ * minx      - {Float} x-coordinate of south western point
+ * miny      - {Float} y-coordinate of south western point
+ * maxx      - {Float} x-coordinate of north eastern point
+ * maxy      - {Float} y-coordinate of north eastern point
+ * 
+ * or parameters (points):
+ * sw    - {Point} south western point
+ * ne    - {Point} north eastern point
+ */
+Mapbender.Extent = function (minx, miny, maxx, maxy) {
+	var that = this;
+
+	var setMin = function (min) {
+		that.min = min;
+		that.minx = min.x;
+		that.miny = min.y;
+	};
+	var setMax = function (max) {
+		that.max = max;
+		that.maxx = max.x;
+		that.maxy = max.y;
+	};
+	
+	var setExtent = function (extent) {
+		that.extent = extent;
+		that.extentx = extent.x;
+		that.extenty = extent.y;
+	};
+	
+	var setCenter = function (center) {
+		that.center = center;
+		that.centerx = center.x;
+		that.centery = center.y;
+	};
+	
+	/**
+	 * Method: set
+	 * 
+	 * Description:
+	 * Allows to set the center (one param) or the extent (two params)
+	 * 
+	 * Parameters (center)
+	 * center	- {Point} center of bounding box
+	 * 
+	 * Parameters (center)
+	 * sw		- {Point} south western point of bounding box
+	 * ne		- {Point} north eastern point of bounding box
+	 */
+	this.set = function (min, max) {
+		// only one parameter (center)
+		if (typeof max === "undefined") {
+			var newLowerLeft = min.minus(this.extent.dividedBy(2));
+			var newUpperRight = min.plus(this.extent.dividedBy(2));
+			setMin(newLowerLeft);
+			setMax(newUpperRight);
+			setCenter(min);
+		}
+		// two parameters (lower left and upper right ( = extent))
+		else {
+			setMin(min);
+			setMax(max);
+			setExtent(max.minus(min));
+			setCenter((min.plus(max)).dividedBy(2));
+		}
+	};
+
+	/**
+	 * Method: toString
+	 * 
+	 * Description:
+	 * Returns a comma-separated list of all four coordinates
+	 */
+	this.toString = function () {
+		return this.min.x + "," + this.min.y + "," + this.max.x + "," + this.max.y;
+	};
+	
+	var isPoint = function (param) {
+		if (typeof param === "object" && param.constructor === Point) {
+			return true;
+		}
+		return false;
+	};
+	
+	if (isPoint(minx) && isPoint(miny) && 
+		typeof maxx === "undefined" && 
+		typeof maxy === "undefined") {
+
+		// input is "point, point"
+		this.set(minx, miny);
+	}
+	else {
+		// input is "coordinate, coordinate, coordinate, coordinate"
+		// deprecated
+		this.set(
+			new Point(parseFloat(minx), parseFloat(miny)),
+			new Point(parseFloat(maxx), parseFloat(maxy))
+		);
+	}
+	return this;
+}

Modified: trunk/mapbender/lib/point.js
===================================================================
--- trunk/mapbender/lib/point.js	2009-07-01 14:42:05 UTC (rev 4273)
+++ trunk/mapbender/lib/point.js	2009-07-01 15:05:08 UTC (rev 4274)
@@ -162,7 +162,7 @@
 		new_min = new Point(min.x, center.y - relation_px_y * extent.x / 2);
 		new_max = new Point(max.x, center.y + relation_px_y * extent.x / 2);
 	}
-	mb_mapObj[ind].extent = new Extent(
+	mb_mapObj[ind].extent = new Mapbender.Extent(
 		new_min.x,
 		new_min.y,
 		new_max.x,



More information about the Mapbender_commits mailing list