[Mapbender-commits] r3864 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Apr 7 14:30:56 EDT 2009


Author: christoph
Date: 2009-04-07 14:30:56 -0400 (Tue, 07 Apr 2009)
New Revision: 3864

Modified:
   trunk/mapbender/http/javascripts/map_obj.js
Log:
http://trac.osgeo.org/mapbender/ticket/433

Modified: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	2009-04-07 18:28:23 UTC (rev 3863)
+++ trunk/mapbender/http/javascripts/map_obj.js	2009-04-07 18:30:56 UTC (rev 3864)
@@ -14,6 +14,10 @@
 		this.extent = String(minx) + "," + String(miny) + "," + String(maxx) + "," + String(maxy);
 	};
 	
+	this.restrictedExtent = function (extent) {
+		this.restrictedExtent = extent;
+	};
+	
 	/**
 	 * get the width of the mapObj
 	 *
@@ -129,10 +133,35 @@
 			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
 			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
 		}
+		
+		// Check if ext is within restricted extent
+		// If not, calculate a new extent according
+		// to restricted extent.
+		/*
+		if ( this.restrictedExtent ) {
+			if ( ext.minx  < this.restrictedExtent.minx ) {  
+	            ext.minx = this.restrictedExtent.minx;
+	            ext.maxx = ext.minx + (relation_px_x * ext.extenty);
+	        }
+	        if ( ext.miny < this.restrictedExtent.miny ) {
+	            ext.miny = this.restrictedExtent.miny;
+	            ext.maxy = ext.miny + (relation_px_y * ext.extentx);
+	        }
+	        if ( ext.maxx > this.restrictedExtent.maxx ) {
+	            ext.maxx = this.restrictedExtent.maxx;
+	            ext.minx = ext.maxx - (relation_px_x * ext.extenty);
+	        }
+	        if ( ext.maxy > this.restrictedExtent.maxy ) {
+	            ext.maxy = this.restrictedExtent.maxy;
+	            ext.miny = ext.maxy - (relation_px_y * ext.extentx);
+	        }
+		}
+		*/
 		this.setExtent(ext.minx, ext.miny, ext.maxx, ext.maxy);
 		return ext;
 	};
 	
+	
 	this.width = width;
 	this.height = height;
 	this.frameName = frameName;
@@ -341,21 +370,31 @@
 				break;
 		}
 		this.extent = minx + "," + miny + "," + maxx + "," + maxy;
+		
+		this.restrictedExtent;
 		this.setMapRequest();
 		
 	};
 	
 	this.zoomFull = function () {
 		
-		for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
-			if (this.epsg == this.wms[0].gui_epsg[i]) {
-				var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
-				var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
-				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 newExtent = this.calculateExtent(wmsExtent);
-				this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+		if (this.restrictedExtent) {
+			var newExtent = this.calculateExtent(this.restrictedExtent);
+			this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+		}
+		else {
+			for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
+				if (this.epsg == this.wms[0].gui_epsg[i]) {
+					var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
+					var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
+					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 newExtent = this.calculateExtent(wmsExtent);
+					this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.maxy));
+					break;
+				}
 			}
 		}
 	};
@@ -378,7 +417,6 @@
 		var distx = extent.maxx - extent.minx;
 		var disty = extent.maxy - extent.miny;
 		
-		
 		if (x && y) {
 			var centerx = parseFloat(x);
 			var centery = parseFloat(y);
@@ -394,6 +432,32 @@
 		var miny = centery - new_disty / 2;
 		var maxx = centerx + new_distx / 2;
 		var maxy = centery + new_disty / 2;
+		// Check if ext is within restricted extent
+		// If not, calculate a new extent according
+		// to restricted extent.
+		/*
+		var relation_px_x = this.getWidth() / this.getHeight();
+		var relation_px_y = this.getHeight() / this.getWidth();
+		if ( this.restrictedExtent ) {
+			if ( minx  < this.restrictedExtent.minx ) {  
+	            minx = this.restrictedExtent.minx;
+	            maxx = minx + (relation_px_x * new_disty);
+	        }
+	        if ( miny < this.restrictedExtent.miny ) {
+	            miny = this.restrictedExtent.miny;
+	            maxy = miny + (relation_px_y * new_distx);
+	        }
+	        if ( maxx > this.restrictedExtent.maxx ) {
+	            maxx = this.restrictedExtent.maxx;
+	            minx = maxx - (relation_px_x * new_distx);
+	        }
+	        if ( maxy > this.restrictedExtent.maxy ) {
+	            maxy = this.restrictedExtent.maxy;
+	            miny = maxy - (relation_px_y * new_disty);
+	        }
+		}
+		*/
+		
 		this.setExtent(minx, miny, maxx, maxy);
 
 		this.setMapRequest();



More information about the Mapbender_commits mailing list