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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Dec 17 11:53:31 EST 2010


Author: astrid_emde
Date: 2010-12-17 08:53:31 -0800 (Fri, 17 Dec 2010)
New Revision: 7338

Added:
   trunk/mapbender/http/javascripts/mod_coordsLookup.php
Removed:
   trunk/mapbender/http/javascripts/mod_coordsLookup.js
Log:
changed to php because of i18n

Deleted: trunk/mapbender/http/javascripts/mod_coordsLookup.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.js	2010-12-17 16:30:35 UTC (rev 7337)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.js	2010-12-17 16:53:31 UTC (rev 7338)
@@ -1,240 +0,0 @@
-/**
- * Package: coordsLookup
- *
- * Description:
- * The user enters a coordinate tuple and selects the corresponding SRS 
- * from a select box. After submitting this form, Mapbender transforms
- * the coordinate tuple to the current SRS and zooms to the location.
- * 
- * Files:
- *  - http/javascripts/mod_coordsLookup.js
- *  - http/php/mod_coordsLookup_server.php
- *
- * SQL:
- * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, 
- * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
- * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
- * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<app_id>','coordsLookup',
- * > 10,1,'','Coordinate lookup','div','','',1000,0,NULL ,NULL ,NULL ,
- * > 'z-index:9999;','','div','mod_coordsLookup.js','',
- * > 'mapframe1','','');
- * >
- * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 
- * > var_value, context, var_type) VALUES ('<app_id>', 'coordsLookup', 
- * > 'perimeters', '[50,200,1000,10000]', '' ,'var');
- * >
- * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 
- * > var_value, context, var_type) VALUES('<app_id>', 'coordsLookup', 
- * > 'projections', '[''EPSG:31467'',''EPSG:31468'',''EPSG:31469'']', '' ,
- * > 'var');
- *
- * Help:
- * http://www.mapbender.org/coordsLookup
- *
- * Maintainer:
- * http://www.mapbender.org/User:Christoph_Baudson
- * 
- * Parameters:
- * perimeters		- Array of perimeters in m, like [50,200,1000,10000]
- * projections		- Array of EPSG names, like ['EPSG:31467','EPSG:31468']
- *
- * 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
- */
-
-//
-// http://trac.osgeo.org/proj4js/wiki/UserGuide
-//
-// 3802000 / 5825000
-var CoordsLookup = function() {
-	var that = this;
-	if(
-		typeof options.target      === 'undefined' || options.target.length      === 0 || 
-		typeof options.projections === 'undefined' || options.projections.length === 0 || 
-		typeof options.perimeters  === 'undefined' || options.perimeters.length  === 0
-	) {
-		
-		return;
-	}
-
-	this.buildForm = function() {
-//		Container elements
-		this.formContainer             = $(document.createElement('form')).attr({'id':'coords-lookup-form'}).appendTo('#' + options.id);
-		this.coordsInputContainer      = $(document.createElement('p')).appendTo(this.formContainer);
-		this.projectionSelectContainer = $(document.createElement('p')).appendTo(this.formContainer);
-		this.perimeterSelectContainer  = $(document.createElement('p')).appendTo(this.formContainer);
-		this.triggerButtonContainer    = $(document.createElement('p')).appendTo(this.formContainer);
-//		Coordinates input with label
-		this.coordsInputLabel          = $(document.createElement('label')).attr({'for':'coord-x'}).text('Koordinaten:').appendTo(this.coordsInputContainer);
-		this.coordXInput               = $(document.createElement('input')).attr({'id':'coord-x','size':8}).appendTo(this.coordsInputContainer);
-		this.coordYInput               = $(document.createElement('input')).attr({'id':'coord-y','size':8}).appendTo(this.coordsInputContainer);
-		$(this.coordsInputLabel).after($(document.createElement('br')));
-		$(this.coordXInput).after('&nbsp;/&nbsp;');
-//		Projection select
-		this.projectionSelect          = $(document.createElement('select')).attr({'id':'projection-select'}).appendTo(this.projectionSelectContainer);
-//		Perimeter select
-		this.perimeterSelect           = $(document.createElement('select')).attr({'id':'perimeter-select'}).appendTo(this.perimeterSelectContainer);		
-//		Trigger button
-		this.triggerButton             = $(document.createElement('input')).attr({'id':'trigger-button','type':'button','value':'Auf Koordinaten zoomen'}).appendTo(this.triggerButtonContainer);		
-	};
-	
-	this.initForm = function() {
-//		Fill projection select with options
-		for(var i = 0; i < options.projections.length; i++) {
-			$(this.projectionSelect).append('<option value=' + options.projections[i] + ' >' + options.projections[i] + '</option>');
-		}
-		//$(new Option('Projektionssystem','Projektionssystem',true,true)).prependTo(this.projectionSelect);
-		$(this.projectionSelect).prepend('<option value="Projektionssystem" selected=selected>Projektionssystem</option>');
-
-//		Fill perimeter select with options	
-		for(var i = 0; i < options.perimeters.length; i++) {
-			var optionValue = options.perimeters[i] + '';
-			
-			optionValue = (optionValue.length < 4) ? (optionValue + ' m') : optionValue.replace(/(\d+)(\d{3})/, '$1' + '.' + '$2' + ' m');
-			
-			$(this.perimeterSelect).append('<option value=' + optionValue + ' >' + optionValue + '</option>');
-		}
-		$(this.perimeterSelect).prepend('<option value="Umkreis" >Umkreis</option>');
-		
-//		Set action for trigger button
-		$(this.triggerButton).click(function() {
-			Mapbender.modules[options.id].zoomToCoordinates();
-		});
-	};
-	
-	this.zoomToCoordinates = function() {
-		this.coords = {};
-
-		this.coords.x                = this.coordXInput.val().replace(',','.');
-		this.coords.y                = this.coordYInput.val().replace(',','.');
-		//check if deg/minutes/seconds have been inserted
-		//validate 
-		this.regexdms = /([0-9.]+)\°([0-9.]+)\'([0-9.]+)\'\'/;
-		
-		this.coords.sourceProjection = (this.projectionSelect.val()) ? 
-			this.projectionSelect.val() : null;
-		this.coords.targetProjection = Mapbender.modules[options.target].getSRS();
-		this.coords.perimeter        = (this.perimeterSelect.val()) ? 
-			parseFloat(this.perimeterSelect.val()) : null;
-		//validate coordinates
-		if(this.coords.x.length === 0 || isNaN(this.coords.x)) {
-			this.regexdms.exec(this.coords.x);
-			//alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
-			if (isNaN(parseFloat(RegExp.$1)) || isNaN(parseFloat(RegExp.$2)) || isNaN(parseFloat(RegExp.$3)))
-			{
-				alert('Invalid X coordinate! Must be a float or a DMS value!');
-				return;
-			} else {
-				this.coords.x = parseFloat(RegExp.$1) + parseFloat(RegExp.$2) / 60.0 + parseFloat(RegExp.$2) / 3600.0;		
-			}
-		}
-		if(this.coords.y.length === 0 || isNaN(this.coords.y)) {
-			this.regexdms.exec(this.coords.y);
-			//alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
-			if (isNaN(parseFloat(RegExp.$1)) || isNaN(parseFloat(RegExp.$2)) || isNaN(parseFloat(RegExp.$3)))
-			{
-				alert('Invalid Y coordinate! Must be a float or a DMS value!');
-				return;
-			} else {
-				this.coords.y = parseFloat(RegExp.$1) + parseFloat(RegExp.$2 / 60.0) + parseFloat(RegExp.$2 / 3600.0);		
-			}
-		}
-		
-		if (this.coords.sourceProjection === null) {
-			alert('Invalid SRS!');
-			return;
-		}
-
-		//if(this.coords.sourceProjection && (this.coords.sourceProjection != this.coords.targetProjection)) {
-		if(this.coords.sourceProjection) {
-			this.transformProjection();
-		}
-
-	};
-	
-	this.transformProjection = function() {
-		var parameters = {
-			fromSrs: this.coords.sourceProjection,
-			toSrs: this.coords.targetProjection
-		};
-		if (this.coords.perimeter === null) {
-			parameters.x = this.coords.x;
-			parameters.y = this.coords.y;
-		}
-		else {
-			if (this.coords.sourceProjection == 'EPSG:4326') {
-				this.R = 6371000.0;
-				this.Pi = Math.PI;
-				this.rho = 180.0/this.Pi;
-				this.coords.perimeterlon = 0.0;
-				this.coords.perimeterlat = 0.0;
-				this.coords.perimeterlon = parseFloat(this.coords.perimeter) * this.rho / this.R;
-				this.coords.perimeterlat = parseFloat(this.coords.perimeter) * this.rho / (this.R * Math.cos(parseFloat(this.coords.y) / this.rho));
-				parameters.bbox = (
-					parseFloat(this.coords.x) - parseFloat(this.coords.perimeterlon)
-					) + "," + (
-					parseFloat(this.coords.y) - parseFloat(this.coords.perimeterlat)
-					) + "," + (
-					parseFloat(this.coords.x) + parseFloat(this.coords.perimeterlon)
-					) + "," + (
-					parseFloat(this.coords.y) + parseFloat(this.coords.perimeterlat));
-			}
-			else {
-			parameters.bbox = (
-				parseFloat(this.coords.x) - parseFloat(this.coords.perimeter)
-				) + "," + (
-				parseFloat(this.coords.y) - parseFloat(this.coords.perimeter)
-				) + "," + (
-				parseFloat(this.coords.x) + parseFloat(this.coords.perimeter)
-				) + "," + (
-				parseFloat(this.coords.y) + parseFloat(this.coords.perimeter));
-			}
-		}
-		var req = new Mapbender.Ajax.Request({
-			url: "../php/mod_coordsLookup_server.php",
-			method: "transform",
-			parameters: parameters,
-			callback: function (obj, success, message) {
-				if (!success) {
-					new Mapbender.Exception(message);
-					return;
-				}
-				
-				var map = Mapbender.modules[options.target];
-				
-				if (obj.points) {
-					
-					if (obj.points.length === 1) {
-						map.setCenter(new Point(
-							obj.points[0].x,
-							obj.points[0].y
-						));
-					}
-					else if (obj.points.length === 2) {
-						var newExtent = new Extent(
-							obj.points[0].x,
-							obj.points[0].y,
-							obj.points[1].x,
-							obj.points[1].y
-						);
-						map.calculateExtent(newExtent);
-						map.setMapRequest();
-						
-					}
-				}
-			} 
-		});
-		req.send();
-	};
-	
-	this.buildForm();
-	this.initForm();
-
-};
-
-Mapbender.events.init.register(function() {
-	Mapbender.modules[options.id] = $.extend(new CoordsLookup(),Mapbender.modules[options.id]);	
-});

Copied: trunk/mapbender/http/javascripts/mod_coordsLookup.php (from rev 7337, trunk/mapbender/http/javascripts/mod_coordsLookup.js)
===================================================================
--- trunk/mapbender/http/javascripts/mod_coordsLookup.php	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_coordsLookup.php	2010-12-17 16:53:31 UTC (rev 7338)
@@ -0,0 +1,240 @@
+/**
+ * Package: coordsLookup
+ *
+ * Description:
+ * The user enters a coordinate tuple and selects the corresponding SRS 
+ * from a select box. After submitting this form, Mapbender transforms
+ * the coordinate tuple to the current SRS and zooms to the location.
+ * 
+ * Files:
+ *  - http/javascripts/mod_coordsLookup.js
+ *  - http/php/mod_coordsLookup_server.php
+ *
+ * SQL:
+ * > INSERT INTO gui_element (fkey_gui_id, e_id, e_pos, e_public, e_comment, 
+ * > e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, 
+ * > e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, 
+ * > e_mb_mod, e_target, e_requires, e_url) VALUES ('<app_id>','coordsLookup',
+ * > 10,1,'','Coordinate lookup','div','','',1000,0,NULL ,NULL ,NULL ,
+ * > 'z-index:9999;','','div','mod_coordsLookup.js','',
+ * > 'mapframe1','','');
+ * >
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 
+ * > var_value, context, var_type) VALUES ('<app_id>', 'coordsLookup', 
+ * > 'perimeters', '[50,200,1000,10000]', '' ,'var');
+ * >
+ * > INSERT INTO gui_element_vars (fkey_gui_id, fkey_e_id, var_name, 
+ * > var_value, context, var_type) VALUES('<app_id>', 'coordsLookup', 
+ * > 'projections', '[''EPSG:31467'',''EPSG:31468'',''EPSG:31469'']', '' ,
+ * > 'var');
+ *
+ * Help:
+ * http://www.mapbender.org/coordsLookup
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * Parameters:
+ * perimeters		- Array of perimeters in m, like [50,200,1000,10000]
+ * projections		- Array of EPSG names, like ['EPSG:31467','EPSG:31468']
+ *
+ * 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
+ */
+
+//
+// http://trac.osgeo.org/proj4js/wiki/UserGuide
+//
+// 3802000 / 5825000
+var CoordsLookup = function() {
+	var that = this;
+	if(
+		typeof options.target      === 'undefined' || options.target.length      === 0 || 
+		typeof options.projections === 'undefined' || options.projections.length === 0 || 
+		typeof options.perimeters  === 'undefined' || options.perimeters.length  === 0
+	) {
+		
+		return;
+	}
+
+	this.buildForm = function() {
+//		Container elements
+		this.formContainer             = $(document.createElement('form')).attr({'id':'coords-lookup-form'}).appendTo('#' + options.id);
+		this.coordsInputContainer      = $(document.createElement('p')).appendTo(this.formContainer);
+		this.projectionSelectContainer = $(document.createElement('p')).appendTo(this.formContainer);
+		this.perimeterSelectContainer  = $(document.createElement('p')).appendTo(this.formContainer);
+		this.triggerButtonContainer    = $(document.createElement('p')).appendTo(this.formContainer);
+//		Coordinates input with label
+		this.coordsInputLabel          = $(document.createElement('label')).attr({'for':'coord-x'}).text('Koordinaten:').appendTo(this.coordsInputContainer);
+		this.coordXInput               = $(document.createElement('input')).attr({'id':'coord-x','size':8}).appendTo(this.coordsInputContainer);
+		this.coordYInput               = $(document.createElement('input')).attr({'id':'coord-y','size':8}).appendTo(this.coordsInputContainer);
+		$(this.coordsInputLabel).after($(document.createElement('br')));
+		$(this.coordXInput).after('&nbsp;/&nbsp;');
+//		Projection select
+		this.projectionSelect          = $(document.createElement('select')).attr({'id':'projection-select'}).appendTo(this.projectionSelectContainer);
+//		Perimeter select
+		this.perimeterSelect           = $(document.createElement('select')).attr({'id':'perimeter-select'}).appendTo(this.perimeterSelectContainer);		
+//		Trigger button
+		this.triggerButton             = $(document.createElement('input')).attr({'id':'trigger-button','type':'button','value':'Auf Koordinaten zoomen'}).appendTo(this.triggerButtonContainer);		
+	};
+	
+	this.initForm = function() {
+//		Fill projection select with options
+		for(var i = 0; i < options.projections.length; i++) {
+			$(this.projectionSelect).append('<option value=' + options.projections[i] + ' >' + options.projections[i] + '</option>');
+		}
+		//$(new Option('Projektionssystem','Projektionssystem',true,true)).prependTo(this.projectionSelect);
+		$(this.projectionSelect).prepend('<option value="Projektionssystem" selected=selected>Projektionssystem</option>');
+
+//		Fill perimeter select with options	
+		for(var i = 0; i < options.perimeters.length; i++) {
+			var optionValue = options.perimeters[i] + '';
+			
+			optionValue = (optionValue.length < 4) ? (optionValue + ' m') : optionValue.replace(/(\d+)(\d{3})/, '$1' + '.' + '$2' + ' m');
+			
+			$(this.perimeterSelect).append('<option value=' + optionValue + ' >' + optionValue + '</option>');
+		}
+		$(this.perimeterSelect).prepend('<option value="Umkreis" >Umkreis</option>');
+		
+//		Set action for trigger button
+		$(this.triggerButton).click(function() {
+			Mapbender.modules[options.id].zoomToCoordinates();
+		});
+	};
+	
+	this.zoomToCoordinates = function() {
+		this.coords = {};
+
+		this.coords.x                = this.coordXInput.val().replace(',','.');
+		this.coords.y                = this.coordYInput.val().replace(',','.');
+		//check if deg/minutes/seconds have been inserted
+		//validate 
+		this.regexdms = /([0-9.]+)\°([0-9.]+)\'([0-9.]+)\'\'/;
+		
+		this.coords.sourceProjection = (this.projectionSelect.val()) ? 
+			this.projectionSelect.val() : null;
+		this.coords.targetProjection = Mapbender.modules[options.target].getSRS();
+		this.coords.perimeter        = (this.perimeterSelect.val()) ? 
+			parseFloat(this.perimeterSelect.val()) : null;
+		//validate coordinates
+		if(this.coords.x.length === 0 || isNaN(this.coords.x)) {
+			this.regexdms.exec(this.coords.x);
+			//alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
+			if (isNaN(parseFloat(RegExp.$1)) || isNaN(parseFloat(RegExp.$2)) || isNaN(parseFloat(RegExp.$3)))
+			{
+				alert('Invalid X coordinate! Must be a float or a DMS value!');
+				return;
+			} else {
+				this.coords.x = parseFloat(RegExp.$1) + parseFloat(RegExp.$2) / 60.0 + parseFloat(RegExp.$2) / 3600.0;		
+			}
+		}
+		if(this.coords.y.length === 0 || isNaN(this.coords.y)) {
+			this.regexdms.exec(this.coords.y);
+			//alert(RegExp.$1 + ";" + RegExp.$2 + ";" + RegExp.$3);
+			if (isNaN(parseFloat(RegExp.$1)) || isNaN(parseFloat(RegExp.$2)) || isNaN(parseFloat(RegExp.$3)))
+			{
+				alert('Invalid Y coordinate! Must be a float or a DMS value!');
+				return;
+			} else {
+				this.coords.y = parseFloat(RegExp.$1) + parseFloat(RegExp.$2 / 60.0) + parseFloat(RegExp.$2 / 3600.0);		
+			}
+		}
+		
+		if (this.coords.sourceProjection === null) {
+			alert('Invalid SRS!');
+			return;
+		}
+
+		//if(this.coords.sourceProjection && (this.coords.sourceProjection != this.coords.targetProjection)) {
+		if(this.coords.sourceProjection) {
+			this.transformProjection();
+		}
+
+	};
+	
+	this.transformProjection = function() {
+		var parameters = {
+			fromSrs: this.coords.sourceProjection,
+			toSrs: this.coords.targetProjection
+		};
+		if (this.coords.perimeter === null) {
+			parameters.x = this.coords.x;
+			parameters.y = this.coords.y;
+		}
+		else {
+			if (this.coords.sourceProjection == 'EPSG:4326') {
+				this.R = 6371000.0;
+				this.Pi = Math.PI;
+				this.rho = 180.0/this.Pi;
+				this.coords.perimeterlon = 0.0;
+				this.coords.perimeterlat = 0.0;
+				this.coords.perimeterlon = parseFloat(this.coords.perimeter) * this.rho / this.R;
+				this.coords.perimeterlat = parseFloat(this.coords.perimeter) * this.rho / (this.R * Math.cos(parseFloat(this.coords.y) / this.rho));
+				parameters.bbox = (
+					parseFloat(this.coords.x) - parseFloat(this.coords.perimeterlon)
+					) + "," + (
+					parseFloat(this.coords.y) - parseFloat(this.coords.perimeterlat)
+					) + "," + (
+					parseFloat(this.coords.x) + parseFloat(this.coords.perimeterlon)
+					) + "," + (
+					parseFloat(this.coords.y) + parseFloat(this.coords.perimeterlat));
+			}
+			else {
+			parameters.bbox = (
+				parseFloat(this.coords.x) - parseFloat(this.coords.perimeter)
+				) + "," + (
+				parseFloat(this.coords.y) - parseFloat(this.coords.perimeter)
+				) + "," + (
+				parseFloat(this.coords.x) + parseFloat(this.coords.perimeter)
+				) + "," + (
+				parseFloat(this.coords.y) + parseFloat(this.coords.perimeter));
+			}
+		}
+		var req = new Mapbender.Ajax.Request({
+			url: "../php/mod_coordsLookup_server.php",
+			method: "transform",
+			parameters: parameters,
+			callback: function (obj, success, message) {
+				if (!success) {
+					new Mapbender.Exception(message);
+					return;
+				}
+				
+				var map = Mapbender.modules[options.target];
+				
+				if (obj.points) {
+					
+					if (obj.points.length === 1) {
+						map.setCenter(new Point(
+							obj.points[0].x,
+							obj.points[0].y
+						));
+					}
+					else if (obj.points.length === 2) {
+						var newExtent = new Extent(
+							obj.points[0].x,
+							obj.points[0].y,
+							obj.points[1].x,
+							obj.points[1].y
+						);
+						map.calculateExtent(newExtent);
+						map.setMapRequest();
+						
+					}
+				}
+			} 
+		});
+		req.send();
+	};
+	
+	this.buildForm();
+	this.initForm();
+
+};
+
+Mapbender.events.init.register(function() {
+	Mapbender.modules[options.id] = $.extend(new CoordsLookup(),Mapbender.modules[options.id]);	
+});



More information about the Mapbender_commits mailing list