[Mapbender-commits] r4502 - in trunk/mapbender/http: javascripts php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 7 08:42:56 EDT 2009


Author: christoph
Date: 2009-08-07 08:42:53 -0400 (Fri, 07 Aug 2009)
New Revision: 4502

Added:
   trunk/mapbender/http/javascripts/mod_changeEPSG.js
Removed:
   trunk/mapbender/http/javascripts/mod_changeEPSG.php
Modified:
   trunk/mapbender/http/php/mod_changeEPSG_server.php
Log:


Added: trunk/mapbender/http/javascripts/mod_changeEPSG.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.js	                        (rev 0)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.js	2009-08-07 12:42:53 UTC (rev 4502)
@@ -0,0 +1,142 @@
+/**
+ * Package: changeEPSG
+ *
+ * Description:
+ * Select a spatial reference system EPSG code. All maps are transformed to 
+ * that system.
+ * 
+ * Files:
+ *  - http/javascripts/mod_changeEPSG.js
+ *  - http/php/mod_changeEPSG_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 ('<gui_id>','changeEPSG',
+ * > 2,1,'change EPSG, Postgres required, overview is targed for full extent',
+ * > 'Change Projection','select','','',432,25,107,24,1,'',
+ * > '<option value="">...</option>
+ * > <option value="EPSG:4326">EPSG:4326</option>
+ * > <option value="EPSG:31466">EPSG:31466</option>
+ * > <option value="EPSG:31467">EPSG:31467</option>
+ * > <option value="EPSG:31468">EPSG:31468</option>
+ * > <option value="EPSG:31469">EPSG:31469</option>','select',
+ * > 'mod_changeEPSG.js','','overview','','');
+ *
+ * Help:
+ * http://www.mapbender.org/ChangeEpsg
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ * 
+ * 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
+ */
+
+var that = this;
+var exists = false;
+
+eventAfterMapRequest.register(function () {
+	mod_changeEPSG_setBox();
+});
+
+function mod_changeEPSG_setBox(){
+	$("#"+options.id+" option").each(function () {
+		if (this.value == mb_mapObj[0].epsg) {
+			isEPSG = true;
+			$(this).attr("selected", "selected");
+		}
+	});
+}
+
+$(this).change(function () {
+	var srsArray = [];
+	for (var i = 0; i < mb_mapObj.length; i++) {
+		var currentSrs = {
+			"frameName" : mb_mapObj[i].elementName,
+			"epsg" : mb_mapObj[i].epsg,
+			"extent" : mb_mapObj[i].extent.toString(),
+			"width" : mb_mapObj[i].width,
+			"height" : mb_mapObj[i].height
+		};
+		srsArray.push(currentSrs);
+	}
+
+	var srsValue = $("#"+options.id).get(0).value;
+	if (srsValue === "") {
+		return;
+	}
+
+	var req = new Mapbender.Ajax.Request({
+		url: "../php/mod_changeEPSG_server.php",
+		method: "changeEpsg",
+		parameters: {
+			srs: srsArray,
+			newSrs: srsValue
+		},
+		callback: function (obj, success, message) {
+			if (!success) {
+				alert(message);
+				new Mapbender.Exception(message);
+				return;
+			}
+			
+			var newExtent = obj;
+			
+			for (var i = 0; i < newExtent.length; i++) {
+				//
+				// use the previous extent of the overview
+				//
+				if(newExtent[i].frameName == options.target){
+	
+					var map = Mapbender.modules[options.target];
+					
+					var goback = false;
+					for (var ii = 0; ii < map.mb_MapHistoryObj.length; ii++) {
+						if (map.mb_MapHistoryObj[ii].epsg == newExtent[i].newSrs) {
+							exists = ii;
+							goback = true;
+						}
+					}
+	
+					if (goback) {
+						map.setSrs({
+							srs: newExtent[i].newSrs, 
+							extent: map.mb_MapHistoryObj[exists].extent
+						});
+					}
+					else{
+						map.setSrs({
+							srs: newExtent[i].newSrs, 
+							extent: new Mapbender.Extent(
+								parseFloat(newExtent[i].minx),
+								parseFloat(newExtent[i].miny), 
+								parseFloat(newExtent[i].maxx),
+								parseFloat(newExtent[i].maxy)
+							)
+						});
+					}
+				}
+				else {
+					var map = Mapbender.modules[newExtent[i].frameName];
+					map.setSrs({
+						srs: newExtent[i].newSrs, 
+						extent: new Mapbender.Extent(
+							parseFloat(newExtent[i].minx),
+							parseFloat(newExtent[i].miny), 
+							parseFloat(newExtent[i].maxx),
+							parseFloat(newExtent[i].maxy)
+						),
+						displayWarning: true
+					});
+				}
+				map.setMapRequest();
+			}
+		} 
+	});
+	req.send();
+});
\ No newline at end of file

Deleted: trunk/mapbender/http/javascripts/mod_changeEPSG.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_changeEPSG.php	2009-08-06 13:45:17 UTC (rev 4501)
+++ trunk/mapbender/http/javascripts/mod_changeEPSG.php	2009-08-07 12:42:53 UTC (rev 4502)
@@ -1,107 +0,0 @@
-<?php
-# $Id:mod_changeEPSG.php 3397 2009-01-02 15:24:40Z christoph $
-# http://www.mapbender.org/index.php/mod_changeEPSG.php
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-?>
-var that = this;
-var exists = false;
-
-eventAfterMapRequest.register(function () {
-	mod_changeEPSG_setBox();
-});
-
-function mod_changeEPSG_setBox(){
-	$("#"+options.id+" option").each(function () {
-		if (this.value == mb_mapObj[0].epsg) {
-			isEPSG = true;
-			$(this).attr("selected", "selected");
-		}
-	});
-}
-
-$(this).change(function () {
-	var srsArray = [];
-	for (var i = 0; i < mb_mapObj.length; i++) {
-		var currentSrs = {
-			"frameName" : mb_mapObj[i].elementName,
-			"epsg" : mb_mapObj[i].epsg,
-			"extent" : mb_mapObj[i].extent.toString(),
-			"width" : mb_mapObj[i].width,
-			"height" : mb_mapObj[i].height
-		};
-		srsArray.push(currentSrs);
-	}
-
-	var req = new Mapbender.Ajax.Request({
-		url: "../php/mod_changeEPSG_server.php",
-		method: "changeEpsg",
-		parameters: {
-			srs: srsArray,
-			newSrs: $("#"+options.id).get(0).value
-		},
-		callback: function (obj, success, message) {
-			if (!success) {
-				new Mapbender.Exception(message);
-				return;
-			}
-			
-			var newExtent = obj;
-			
-			for (var i = 0; i < newExtent.length; i++) {
-				if(newExtent[i].frameName == options.target){
-	
-					var map = Mapbender.modules[options.target];
-					
-					for (var ii = 0; ii < map.mb_MapHistoryObj.length; ii++) {
-						if (map.mb_MapHistoryObj[ii].epsg == newExtent[i].newSrs) {
-							exists = ii;
-							var goback = true;
-						}
-					}
-	
-					if (goback) {
-						map.epsg = newExtent[i].newSrs;
-						map.extent = map.mb_MapHistoryObj[exists].extent;
-						map.setMapRequest();
-					}
-					else{
-						map.epsg = newExtent[i].newSrs;
-						map.extent = new Mapbender.Extent(
-							parseFloat(newExtent[i].minx), 
-							parseFloat(newExtent[i].miny),
-							parseFloat(newExtent[i].maxx), 
-							parseFloat(newExtent[i].maxy)
-						);
-						map.setMapRequest();
-					}
-				}
-				else {
-					var map = Mapbender.modules[newExtent[i].frameName];
-					map.epsg = newExtent[i].newSrs;
-					map.extent = new Mapbender.Extent(
-						parseFloat(newExtent[i].minx),
-						parseFloat(newExtent[i].miny), 
-						parseFloat(newExtent[i].maxx),
-						parseFloat(newExtent[i].maxy)
-					);
-					map.setMapRequest();
-				}
-			}
-		} 
-	});
-	req.send();
-});
\ No newline at end of file

Modified: trunk/mapbender/http/php/mod_changeEPSG_server.php
===================================================================
--- trunk/mapbender/http/php/mod_changeEPSG_server.php	2009-08-06 13:45:17 UTC (rev 4501)
+++ trunk/mapbender/http/php/mod_changeEPSG_server.php	2009-08-07 12:42:53 UTC (rev 4502)
@@ -21,10 +21,16 @@
 
 $epsgObj = array();
 
-$ajaxResponse = new AjaxResponse($_REQUEST);
+$ajaxResponse = new AjaxResponse($_POST);
 
 switch ($ajaxResponse->getMethod()) {
 	case "changeEpsg" :
+		if (!Mapbender::postgisAvailable()) {
+			$ajaxResponse->setSuccess(false);
+			$ajaxResponse->setMessage(_mb("PostGIS is not available. Please contact the administrator."));
+			$ajaxResponse->send();
+		}
+
 		$epsgArray = $ajaxResponse->getParameter("srs");
 		$newSrs = $ajaxResponse->getParameter("newSrs");
 



More information about the Mapbender_commits mailing list