[Mapbender-commits] r2476 - in branches/beck_dev/mapbender:
http/classes http/javascripts http/php lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Wed May 28 11:03:41 EDT 2008
Author: christoph
Date: 2008-05-28 11:03:41 -0400 (Wed, 28 May 2008)
New Revision: 2476
Added:
branches/beck_dev/mapbender/lib/map.js
branches/beck_dev/mapbender/lib/point.js
branches/beck_dev/mapbender/lib/style.js
branches/beck_dev/mapbender/lib/wfs_obj.js
Removed:
branches/beck_dev/mapbender/http/javascripts/map.js
branches/beck_dev/mapbender/http/javascripts/point.js
branches/beck_dev/mapbender/http/javascripts/style.js
branches/beck_dev/mapbender/http/javascripts/wfs_obj.js
branches/beck_dev/mapbender/http/php/mb_listWMCs.php
branches/beck_dev/mapbender/http/php/mod_createJSObjFromDB.php
Modified:
branches/beck_dev/mapbender/http/classes/class_map.php
branches/beck_dev/mapbender/http/classes/class_user.php
branches/beck_dev/mapbender/http/classes/class_wmc.php
branches/beck_dev/mapbender/http/classes/class_wms.php
branches/beck_dev/mapbender/http/javascripts/map.php
branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.php
Log:
create WMC from application
Modified: branches/beck_dev/mapbender/http/classes/class_map.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_map.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/classes/class_map.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -15,12 +15,22 @@
private $wmsArray = array();
/**
+ * @destructor
+ * @param
+ */
+ function __destruct() {
+ }
+
+ /**
* @constructor
* @param
*/
function __construct() {
}
+ //-------------------------------------------------------------------------
+ // getter and setter
+ //-------------------------------------------------------------------------
/**
* @param $value Integer
*/
@@ -59,6 +69,14 @@
}
/**
+ *
+ * @return String
+ */
+ public function getFrameName () {
+ return $this->frameName;
+ }
+
+ /**
* @param $value String
*/
public function setExtent ($aMapbenderBbox) {
@@ -66,22 +84,7 @@
}
/**
- * @param $value Object
- */
- public function addWms ($value) {
- array_push($this->wms, $value);
- }
-
- /**
*
- * @return String EPSG code of the map.
- */
- public function getEpsg () {
- return $this->extent->epsg;
- }
-
- /**
- *
* @return Mapbender_bbox
*/
public function getExtent () {
@@ -90,10 +93,10 @@
/**
*
- * @return String
+ * @return String EPSG code of the map.
*/
- public function getFrameName () {
- return $this->frameName;
+ public function getEpsg () {
+ return $this->extent->epsg;
}
/**
@@ -125,10 +128,34 @@
$this->isOverview = $bool;
}
+ /**
+ * @param $value Object
+ */
+ public function addWms ($value) {
+ array_push($this->wms, $value);
+ }
+
+
+ // ------------------------------------------------------------------------
+ // map manipulation
+ // ------------------------------------------------------------------------
+
+ /**
+ * Appends the WMS of another map to this map.
+ *
+ * @param $anotherMap Map
+ */
public function append ($anotherMap) {
$this->wmsArray = array_merge($anotherMap->getWmsArray(), $this->wmsArray);
}
+ /**
+ * Merges this map with another map: Copies the map settings from the
+ * other map and merges the WMS (keeping the settings of the other
+ * map if there are duplicates)
+ *
+ * @param $anotherMap Map
+ */
public function merge ($anotherMap) {
$this->width = $anotherMap->width;
$this->height = $anotherMap->height;
@@ -138,7 +165,10 @@
$this->isOverview = $anotherMap->isOverview;
$this->wmsArray = wms::merge(array_merge($anotherMap->getWmsArray(), $this->wmsArray));
}
-
+
+ // ------------------------------------------------------------------------
+ // Instantiation
+ // ------------------------------------------------------------------------
/**
*
* @return
@@ -255,11 +285,31 @@
return true;
}
+
+ // ------------------------------------------------------------------------
+ // database functions
+ // ------------------------------------------------------------------------
+ public static function selectMainMapByApplication ($appId) {
+ return map::selectByApplication($appId, "mapframe1");
+ }
+
+ public static function selectOverviewMapByApplication ($appId) {
+ $currentMap = map::selectByApplication($appId, "overview");
+ if ($currentMap !== null) {
+ $currentMap->setIsOverview(true);
+ }
+ return $currentMap;
+ }
+
+
+ // ------------------------------------------------------------------------
+ // Output
+ // ------------------------------------------------------------------------
/**
* Returns an array of string, which are JS statements.
* @return String[]
*/
- public function createJsObj ($wmsIndex) {
+ public function toJavaScript ($wmsIndex) {
$jsCodeArray = array();
// initialise map object
@@ -303,46 +353,65 @@
array_push($jsCodeArray, $calcExtentString);
return $jsCodeArray;
}
-
- /**
- * @destructor
- * @param
- */
- function __destruct() {
- }
-}
-/**
- * A JSON output class for Map
- *
- * @class
- */
-class Map2JSON extends Map {
-
- var $json;
+ // ------------------------------------------------------------------------
+ // PRIVATE FUNCTIONS
+ // ------------------------------------------------------------------------
- /**
- * @param
- */
- function __toString() {
- $this->encodeJSON();
+ private static function selectByApplication ($appId, $frameName) {
+ // find the mapframe in the application elements...
+ $sql = "SELECT * FROM gui_element WHERE fkey_gui_id = $1 AND " .
+ "e_id = $2 LIMIT 1";
+ $v = array($appId, $frameName);
+ $t = array('s', 's');
+ $res = db_prep_query($sql,$v,$t);
+ $row = db_fetch_array($res);
- return (string)$this->json;
+ // if found...
+ if ($row) {
+ $currentMap = new Map();
+
+ // use settings from database
+ $currentMap->setWidth($row["e_width"]);
+ $currentMap->setHeight($row["e_height"]);
+ $currentMap->setFrameName($row["e_id"]);
+
+ // get the WMS
+ $wmsArray = wms::selectMyWmsByApplication($appId);
+
+// $e = new mb_notice("WMS in this map: " . implode(",", $wmsArray));
+
+ // if this is the overview, find the WMS index and
+ // reset the WMS array
+ // BEWARE, SUPER UGLY CODE AHEAD!!
+ // (BUT THERE IS NO OTHER WAY TO DO IT)
+ if (strpos($row["e_src"], "mod_mapOV.php?wms") !== false) {
+// $e = new mb_exception("guess this is the OV");
+ $pattern = "/[\.\/a-zA-Z_]*\?wms=([0-9]*)[^0-9]*/";
+ $ovIndex = preg_replace($pattern, "\$1", $row["e_src"]);
+ $e = new mb_exception("OV index: " . $ovIndex);
+ if (!$ovIndex) {
+ $ovIndex = 0;
+ }
+ $wmsArray = array($wmsArray[$ovIndex]);
+// $e = new mb_notice("WMS in this map (corrected): " . implode(",", $wmsArray));
+ }
+ else {
+// $e = new mb_exception("guess this is NOT the OV");
+ }
+
+ $currentMap->wmsArray = $wmsArray;
+
+ // TO DO: EXTENT!
+
+ return $currentMap;
+ }
+ else {
+ return null;
+ }
}
- /**
- *@param
- */
- function encodeJSON() {
- $this->json = json_encode(get_object_vars($this));
- }
-
- /**
- *@param
- */
- function getJSON() {
- return $this->json;
- }
+
}
?>
\ No newline at end of file
Modified: branches/beck_dev/mapbender/http/classes/class_user.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_user.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/classes/class_user.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -38,6 +38,13 @@
}
/**
+ * @return String the ID of this user
+ */
+ public function __toString () {
+ return (string) $this->id;
+ }
+
+ /**
* Returns an array of application IDs that the user is allowed to access.
*
* @return Array an array of application IDs
Modified: branches/beck_dev/mapbender/http/classes/class_wmc.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wmc.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/classes/class_wmc.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -125,7 +125,7 @@
}
// ---------------------------------------------------------------------------
- // CREATION OF A WMC
+ // INSTANTIATION
// ---------------------------------------------------------------------------
/**
@@ -149,6 +149,12 @@
$this->createObjFromWMC_xml($doc);
}
+ public function createFromApplication ($appId) {
+ // get the map objects "overview" and "mapframe1"
+ $this->mainMap = map::selectMainMapByApplication($appId);
+ $this->overviewMap = map::selectOverviewMapByApplication($appId);
+ }
+
/**
* Creates a WMC object from a JS map object {@see map_obj.js}
*
@@ -360,12 +366,12 @@
}
}
}
- $wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->createJsObj($overviewWmsIndex));
+ $wmcJsArray = array_merge($wmcJsArray, $this->overviewMap->toJavaScript($overviewWmsIndex));
}
// .. and add main map ..
- $wmcJsArray = array_merge($wmcJsArray, $this->mainMap->createJsObj(null));
+ $wmcJsArray = array_merge($wmcJsArray, $this->mainMap->toJavaScript(null));
// Finally, request the maps
array_push($wmcJsArray, "setMapRequest('" . $this->mainMap->getFrameName() . "');");
@@ -376,7 +382,10 @@
array_push($wmcJsArray, "eventAfterLoadWMS.trigger()");
return $wmcJsArray;
}
-
+
+ // ------------------------------------------------------------------------
+ // manipulation
+ // ------------------------------------------------------------------------
/**
* Merges this WMC with another WMC.
* The settings of the other WMC overwrite the settings of this WMC.
Modified: branches/beck_dev/mapbender/http/classes/class_wms.php
===================================================================
--- branches/beck_dev/mapbender/http/classes/class_wms.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/classes/class_wms.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -19,12 +19,12 @@
include_once(dirname(__FILE__)."/../../conf/mapbender.conf");
require_once(dirname(__FILE__)."/class_connector.php");
+require_once(dirname(__FILE__)."/class_user.php");
require_once(dirname(__FILE__)."/class_mb_exception.php");
require_once(dirname(__FILE__)."/class_administration.php");
$con = db_connect(DBSERVER,OWNER,PW);
db_select_db(DB,$con);
-
class wms {
var $lastURL;
@@ -122,6 +122,7 @@
* when an error occured.
* @param $anotherWms wms The same WMS with possibly other settings
*/
+/*
public function copyConfiguration ($anotherWms) {
if (!$this->equals($anotherWms)) {
$e = new mb_exception("class_wms.php: copyConfiguration(): parameters cannot be copied, it's a different WMS.");
@@ -138,8 +139,8 @@
$myCurrentLayer->gui_layer_style = $theirCurrentLayer->gui_layer_style;
}
}
+*/
-
/**
* Removes duplicate WMS from an array of WMS. To find duplicates,
* two WMS are compared via equals().
@@ -1926,6 +1927,40 @@
die();
}
}
+
+ /**
+ * Selects all WMS of the current user from the database.
+ * Then it creates the corresponding WMS object and returns
+ * these objects as an array.
+ *
+ * @return wms[]
+ * @param $appId String
+ */
+ public static function selectMyWmsByApplication ($appId) {
+ // check if user is permitted to access the application
+ $currentUser = new User($_SESSION["mb_user_id"]);
+ $appArray = $currentUser->getApplicationsByPermission(false);
+ if (!in_array($appId, $appArray)) {
+ $e = new mb_warning("class_wms.php: selectMyWmsByApplication(): User '" . $currentUser . "' is not allowed to acces application '" . $appId . "'.");
+ return array();
+ }
+
+ // get WMS of this application
+ $sql = "SELECT fkey_wms_id FROM gui_wms WHERE " .
+ "fkey_gui_id = $1 ORDER BY gui_wms_position";
+ $v = array($appId);
+ $t = array('s');
+ $res = db_prep_query($sql,$v,$t);
+
+ // instantiate PHP objects and store in array
+ $wmsArray = array();
+ while ($row = db_fetch_array($res)) {
+ $currentWms = new wms();
+ $currentWms->createObjFromDB($appId, $row["fkey_wms_id"]);
+ array_push($wmsArray, $currentWms);
+ }
+ return $wmsArray;
+ }
}
class layer extends wms {
var $layer_id;
Deleted: branches/beck_dev/mapbender/http/javascripts/map.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map.js 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/map.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,1200 +0,0 @@
-var ie = document.all?1:0;
-var n6 = document.getElementById&&!document.all?1:0;
-var n4 = document.layers?1:0;
-
-var mb_mapObj = [];
-var mb_fiWin = null;
-var mb_panActive = false;
-var clickX;
-var clickY;
-var mb_start_x = 0;
-var mb_start_y = 0;
-var mb_end_x = 0;
-var mb_end_y = 0;
-var mb_offset_top = 0;
-var mb_offset_right = 0;
-var mb_offset_bottom = 0;
-var mb_offset_left = 0;
-var mb_log = null;
-
-/**
- * @deprecated
- */
-function mb_execloadWmsSubFunctions(){
- eventAfterLoadWMS.trigger();
-}
-
-function mb_execWfsReadSubFunctions(geom) {
- for(var i=0; i<mb_WfsReadSubFunctions.length; i++){
- mb_WfsReadSubFunctions[i](geom);
- }
-}
-
-function mb_execWfsWriteSubFunctions() {
- for(var i=0; i<mb_WfsWriteSubFunctions.length; i++){
- mb_WfsWriteSubFunctions[i]();
- }
-}
-
-function mb_setWmcExtensionData(anArray) {
- for (var i in anArray) {
- if (typeof(anArray[i]) != "undefined") {
- currentWmcExtensionData[i] = anArray[i];
- }
- }
-}
-
-function mb_getWmcExtensionData(arrayKey) {
- for (var i in restoredWmcExtensionData) {
- if (arrayKey == i) {
- return restoredWmcExtensionData[i];
- }
- }
- var e = new Mb_warning("mb_getWmcExtensionData: "+arrayKey+" not found. Maybe this GUI does not allow loading or saving WMC documents from/to the session");
- return null;
-}
-
-// transparent GIF
-var mb_trans = new Image();
-mb_trans.src = "../img/transparent.gif";
-
-
-/**
- * Called in index.php on body onload
- */
-function init() {
- // creates the map objects (mapframe1, overview...)
- eventInitMap.trigger();
-
- // initialisation
- eventInit.trigger();
-
- // performs a map request for each map frame
- for(var i=0; i<mb_mapObj.length; i++){
- setMapRequest(mb_mapObj[i].frameName);
- }
-}
-
-function mb_registerMapObj(frameName, elementName,wms_index,width, height){
- mb_mapObj.push(new mb_mapObj_const(frameName, elementName, width, height, wms_index));
-}
-
-/*
- * get the conjunction character of an URL
- * @param {String} onlineresource
- * @return the character & or ?
- * @type String
- */
-function mb_getConjunctionCharacter(onlineresource){
- var conChar;
- if(onlineresource.indexOf("?") > -1){
- if(onlineresource.charAt(onlineresource.length-1) == "?"){
- conChar = "";
- }else if(onlineresource.charAt(onlineresource.length-1) == "&"){
- conChar = "";
- }else{
- conChar = "&";
- }
- }
- if(onlineresource.indexOf("?") == -1){
- conChar = "?";
- }
- return conChar;
-}
-
-
-function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
- if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
- var changed = false;
- var i;
- var result;
- if (fromIndex > toIndex) {
- for (i = fromIndex; i > toIndex ; i--) {
- result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
- if (result === true) {
- changed = true;
- }
- }
- }
- else {
- for (i = fromIndex; i < toIndex ; i++) {
- result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
- if (result === true) {
- changed = true;
- }
- }
- }
- return changed;
- }
- else {
- return false;
- }
-}
-
-function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
- if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
- upper = mb_mapObj[mapObj_ind].wms[indexA];
- mb_mapObj[mapObj_ind].wms[indexA] = mb_mapObj[mapObj_ind].wms[indexB];
- mb_mapObj[mapObj_ind].wms[indexB] = upper;
- var upperLayers = mb_mapObj[mapObj_ind].layers[indexA];
- var upperStyles = mb_mapObj[mapObj_ind].styles[indexA];
- var upperQuerylayers = mb_mapObj[mapObj_ind].querylayers[indexA];
- mb_mapObj[mapObj_ind].layers[indexA] = mb_mapObj[mapObj_ind].layers[indexB];
- mb_mapObj[mapObj_ind].styles[indexA] = mb_mapObj[mapObj_ind].styles[indexB];
- mb_mapObj[mapObj_ind].querylayers[indexA] = mb_mapObj[mapObj_ind].querylayers[indexB];
- mb_mapObj[mapObj_ind].layers[indexB] = upperLayers;
- mb_mapObj[mapObj_ind].styles[indexB] = upperStyles;
- mb_mapObj[mapObj_ind].querylayers[indexB] = upperQuerylayers;
- return true;
- }
- else {
- return false;
- }
-}
-
-function mb_mapObjaddWMS(obj){
- var cnt_layers = 0;
- var cnt_querylayers = 0;
- var styles = "";
- var layers = "";
- var querylayers = "";
- var ind = getMapObjIndexByName(obj);
- //is the id valid?
- for( var i=0; i<(wms.length-1); i++){
- if(parseInt(wms[i].wms_id, 10) >= parseInt(wms[wms.length-1].wms_id, 10)){
- wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id, 10) + 1;
- }
- }
- mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
- mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
- mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
- mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;
- mb_execloadWmsSubFunctions();
- return true;
-}
-function mb_mapObjremoveWMS(objind,wmsind){
- var wms_ID = null;
- var i;
- var new_wmsarray = [];
- var new_layerarray = [];
- var new_querylayerarray = [];
- var new_stylesarray = [];
- var new_mapURLarray = [];
-
- for (i=0;i<mb_mapObj[objind].wms.length; i++){
- if(i != wmsind){
- new_wmsarray[new_wmsarray.length] = mb_mapObj[objind].wms[i];
- new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
- new_querylayerarray[new_querylayerarray.length] = mb_mapObj[objind].querylayers[i];
- new_stylesarray[new_stylesarray.length] = mb_mapObj[objind].styles[i];
- new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i];
- }
- else {
- wms_ID = mb_mapObj[objind].wms[i].wms_id;
- }
- }
- mb_mapObj[objind].wms = new_wmsarray;
- mb_mapObj[objind].layers = new_layerarray;
- mb_mapObj[objind].querylayers = new_querylayerarray;
- mb_mapObj[objind].styles = new_stylesarray;
- mb_mapObj[objind].mapURL = new_mapURLarray;
-
- var another_new_wmsarray = [];
- for (i=0;i<wms.length; i++){
- if(wms[i].wms_id != wms_ID){
- another_new_wmsarray[another_new_wmsarray.length] = wms[i];
- }
- }
- wms = another_new_wmsarray;
-}
-function setExtent(width,height,epsg){
- for(var i=0; i < wms[0].gui_epsg.length; i++){
- if(wms[0].gui_epsg[i] == epsg){
- var bbox_minx = parseFloat(wms[0].gui_minx[i]);
- var bbox_miny = parseFloat(wms[0].gui_miny[i]);
- var bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
- var bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
-
- var extenty = bbox_maxy - bbox_miny;
- var extentx = bbox_maxx - bbox_minx;
-
- var relation_px_x = width / height;
- var relation_px_y = height / width;
- var relation_bbox_x = extentx / extenty;
- var centerx = bbox_minx + (extentx/2);
- var centery = bbox_miny + (extenty/2);
- if(relation_bbox_x <= relation_px_x){
- bbox_minx = centerx - relation_px_x * extenty / 2;
- bbox_maxx = centerx + relation_px_x * extenty / 2;
- }
-
- if(relation_bbox_x > relation_px_x){
- bbox_miny = centery - relation_px_y * extentx / 2;
- bbox_maxy = centery + relation_px_y * extentx / 2;
- }
- return bbox_minx +","+ bbox_miny +","+ bbox_maxx +","+ bbox_maxy;
- }
- }
-}
-function setMapRequest(frameName){
- var functionName = 'setMapRequest';
-
- var ret = eventBeforeMapRequest.trigger({frameName:frameName}, "AND");
- if (ret === false) {
- return true;
- }
-
- var ts = mb_timestamp();
- var myMapIds = [];
- for (var i=0; i < mb_mapObj.length; i++){
- var currentMapObject = mb_mapObj[i];
- if (currentMapObject.frameName != frameName) {
- continue;
- }
-
- var newMapRequest = "";
- for (var ii = 0; ii < currentMapObject.wms.length; ii++){
- var currentWms = currentMapObject.wms[ii];
- if (!(currentWms.gui_wms_visible > 0)) {
- continue;
- }
- myMapIds.push("map_"+ii);
-
- newMapRequest += getLayerHtmlCode(frameName, i, ii);
-
- }
- writeTag(mb_mapObj[i].frameName, mb_mapObj[i].elementName, newMapRequest);
- }
- eventAfterMapRequest.trigger({
- "frameName": frameName,
- "myMapIds": myMapIds.join(",")
- });
-/*
- for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
- eval(mb_MapRequestSubFunctions[i]);
- }
-*/
-}
-
-function getLayerHtmlCode (frameName, i, ii) {
- var currentMapObject = mb_mapObj[i];
- var currentWms = currentMapObject.wms[ii];
-
- var myDivId = "div_" + ii;
- var myMapId = "map_" + ii;
- //disable Layer which are out of scale
- var validLayers = mb_checkScale(frameName, i, ii);
- var layerNames = validLayers.toString();
-
- var newMapURL = false;
- var opacityString = "";
- if (currentMapObject.layers[ii] !== "" && layerNames !== ''){
- // get map URL
- newMapURL = currentMapObject.getMapUrl(i, ii);
-
- var currentOpacity = currentWms.gui_wms_mapopacity;
- if (currentOpacity != 1) {
- opacityString += "opacity:" + currentOpacity + "; ";
- opacityString += "Filter: Alpha(Opacity=" + currentOpacity*100 + "); ";
- opacityString += "-moz-opacity:" + currentOpacity + " ; ";
- opacityString += "-khtml-opacity:" + currentOpacity;
- }
- }
-
- var imageString = "<img id='"+myMapId+"' name='mapimage' ";
- imageString += "src='" + newMapURL + "' ";
- imageString += "width='"+currentMapObject.width+"' ";
- imageString += "height='"+currentMapObject.height+"' ";
- imageString += "border='0'>";
-
- var newMapRequest = "<div id='"+myDivId+"' ";
- newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
- newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
- newMapRequest += imageString;
- newMapRequest += "</div>";
-
- currentMapObject.mapURL[ii]= newMapURL;
- currentWms.mapURL = newMapURL;
-
- if (mb_log && currentWms.mapURL) {
- var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
- }
-
- return newMapRequest;
-}
-
-function setSingleMapRequest(frameName,wms_id){
- var functionName = 'setSingleMapRequest';
-
- eventBeforeMapRequest.trigger({frameName:frameName});
-
- var ts = mb_timestamp();
-
- for(i = 0; i < mb_mapObj.length; i++){
- var currentMapObject = mb_mapObj[i];
- if (currentMapObject.frameName != frameName) {
- continue;
- }
-
- for (var ii=0; ii < currentMapObject.wms.length; ii++){
- var currentWms = currentMapObject.wms[ii];
- if (currentWms.wms_id != wms_id) {
- continue;
- }
-
- var newMapRequest = getLayerHtmlCode(frameName, i, ii);
-
- if (mb_log) {
- var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
- }
- var myDivId = "div_" + ii;
- writeTag(currentMapObject.frameName, myDivId, newMapRequest);
- var myMapId = "map_" + ii;
- eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
- return true;
- }
- }
- return false;
-}
-
-
-function mb_restateLayers(frameName,wms_id){
- //alert(frameName + " / " + wms_id);
- var ind = getMapObjIndexByName(frameName);
- for(var i=0; i<mb_mapObj[ind].wms.length; i++){
- if(mb_mapObj[ind].wms[i].wms_id == wms_id){
- var cnt_layers = 0;
- var cnt_querylayers = 0;
- var layers = "";
- var styles = "";
- var querylayers = "";
- for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
- if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible == 1 && !mb_mapObj[ind].wms[i].objLayer[ii].has_childs){
- if(cnt_layers > 0){layers += ","; styles += ","; }
- layers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
- //alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
- styles += "";
- cnt_layers++;
- }
- if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer == 1 && !mb_mapObj[ind].wms[i].objLayer[ii].has_childs){
- if(cnt_querylayers > 0){querylayers += ",";}
- querylayers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
- cnt_querylayers++;
- }
- }
- mb_mapObj[ind].layers[i] = layers;
- mb_mapObj[ind].querylayers[i] = querylayers;
- mb_mapObj[ind].styles[i] = styles;
- }
- }
-}
-
-function mb_checkScale(frameName,mObj,wmsObj){
- var thisLayer = mb_mapObj[mObj].layers[wmsObj].split(",");
- var thisScale = mb_getScale(frameName);
- var str_layer = "";
- var cnt_layer = 0;
- for(var i=0; i<mb_mapObj[mObj].wms[wmsObj].objLayer.length; i++){
- var myLayername = mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_name;
- var myMinscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_minscale;
- var myMaxscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_maxscale;
- for(var ii=0; ii<thisLayer.length; ii++){
- var minscaleOK = false;
- var maxscaleOK = false;
- if(thisLayer[ii] == myLayername){
- if(myMinscale === 0 || thisScale >= myMinscale){minscaleOK = true;}
- if(myMaxscale === 0 || thisScale <= myMaxscale){maxscaleOK = true;}
- if(maxscaleOK === true && minscaleOK === true && !mb_mapObj[mObj].wms[wmsObj].objLayer[i].has_childs){
- if(cnt_layer > 0){str_layer += ","; }//str_styles += ","; str_titles += ",";str_parent += ","; str_legendurls += ",";}
- str_layer += thisLayer[ii];
- cnt_layer++;
- }
- }
- }
- }
- var str_layerstyles = [];
- str_layerstyles[0] = str_layer;
- return str_layerstyles;
-}
-function setFeatureInfoRequest(fName,x,y, path) {
- var functionName = 'setFeatureInfoRequest';
- var ts = mb_timestamp();
- eventBeforeFeatureInfo.trigger({"fName":fName});
-/*
- for(var i=0; i<mb_FeatureInfoPreFunctions.length; i++){
- eval(mb_FeatureInfoPreFunctions[i]);
- }
-*/
- var cnt_fi = 0;
- for(i=0; i<mb_mapObj.length; i++){
- if(mb_mapObj[i].frameName == fName){
- for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
- var newfeatureInfoRequest = "";
- var requestParams = "";
- var validation = false;
- newfeatureInfoRequest += mb_mapObj[i].wms[ii].wms_getfeatureinfo;
- newfeatureInfoRequest += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getfeatureinfo);
-
- if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){requestParams += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=feature_info&";}
- if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){requestParams += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetFeatureInfo&SERVICE=WMS&";}
- requestParams += "SRS="+mb_mapObj[i].epsg+"&";
- requestParams += "BBOX="+mb_mapObj[i].extent+"&";
- requestParams += "WIDTH="+mb_mapObj[i].width+"&";
- requestParams += "HEIGHT="+mb_mapObj[i].height+"&";
- requestParams += "LAYERS="+mb_mapObj[i].layers[ii]+"&";
- requestParams += "STYLES="+mb_mapObj[i].styles[ii]+"&";
- requestParams += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
- requestParams += "INFO_FORMAT="+mb_mapObj[i].wms[ii].gui_wms_featureinfoformat+"&";
- requestParams += "EXCEPTIONS=application/vnd.ogc.se_xml&";
- if(mb_feature_count > 0){
- requestParams += "FEATURE_COUNT="+mb_feature_count+"&";
- }
- requestParams += "QUERY_LAYERS="+mb_mapObj[i].querylayers[ii]+"&";
- requestParams += "X=" + x + "&";
- requestParams += "Y=" + y;
-
- if(mb_mapObj[i].querylayers[ii] !== "" && mb_mapObj[i].layers[ii] !== ""){
- validation = true;
- }
- //add vendor-specific
- for(var v=0; v < mb_vendorSpecific.length; v++){
- var vendorSpecificString = eval(mb_vendorSpecific[v]);
- requestParams += "&" + vendorSpecificString;
- }
- if(mb_log && validation){
- var tmp = eval(mb_log + "('" + newfeatureInfoRequest + requestParams + "','" + ts + "')");
- }
- if(document.getElementById("FeatureInfoRedirect") && validation){
- newfeatureInfoRequest += requestParams;
- if(path){
- window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
- }
- else{
- window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
- }
- cnt_fi++;
- }
- else if(path && validation){
- newfeatureInfoRequest += requestParams;
- try{
- var p = new mb_popup("Feature Info","url:"+path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr,300,400);
- p.show();
- }catch(e){
- window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
- }
- cnt_fi++;
- }
- else if(validation){
- newfeatureInfoRequest += requestParams;
- try{
- var p = new mb_popup("Feature Info","url:"+newfeatureInfoRequest,300,400);
- p.show();
- }
- catch(e){
- window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
- }
- cnt_fi++;
- }
- }
- }
- }
- if(cnt_fi === 0){
- alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
- }
-}
-
-/*
- * global function to zoom a mapobject
- *
- * use: mb_mapObj.zoom() {@link mb_mapObj_const#zoom}
- * @deprecated
- *
- */
-function zoom(frameName,in_, factor,x,y) {
- var obj = getMapObjByName(frameName);
- if(x && y){
- obj.zoom(in_, factor, x, y);
- }
- else{
- obj.zoom(in_, factor, false, false);
- }
- setMapRequest(frameName);
-}
-function mb_panMap(frameName,dir){
- var ind = getMapObjIndexByName(frameName);
- var arrayBBox = mb_mapObj[ind].extent.split(",");
- var minx = parseFloat(arrayBBox[0]);
- var miny = parseFloat(arrayBBox[1]);
- var maxx = parseFloat(arrayBBox[2]);
- var maxy = parseFloat(arrayBBox[3]);
- var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
- var xtenty = parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
-
- if(dir == "NW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
- if(dir == "N"){miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
- if(dir == "NE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
- if(dir == "W"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2);}
- if(dir == "E"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2);}
- if(dir == "SW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
- if(dir == "S"){miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
- if(dir == "SE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
- mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
- setMapRequest(frameName);
-}
-
-function handleSelectedLayer (frameName, wms_title, layerName, type, status) {
-// alert(frameName + " , " +wms_title + " , " +layerName + " , " +type + " , " +status);
-// type = {visible || querylayer] status = {0 || 1}
- for (var i=0; i < mb_mapObj.length; i++) {
- if (mb_mapObj[i].frameName == frameName) {
- var cnt_layer = 0;
- var str_layer = "";
- var myMapObj = i;
- for (var ii = 0; ii < mb_mapObj[i].wms.length; ii++) {
- if (mb_mapObj[i].wms[ii].wms_title == wms_title) { //ii is true
- var myWMS = ii;
- if (type == "visible") {
- var arrayLayer = mb_mapObj[i].layers[ii].split(",");
- }
- if (type == "querylayer") {
- var arrayLayer = mb_mapObj[i].querylayers[ii].split(",");
- }
- for (var iii = 1; iii < mb_mapObj[i].wms[ii].objLayer.length; iii++) {
- var layer_name = mb_mapObj[i].wms[ii].objLayer[iii].layer_name;
- if (type == "querylayer") {
- if (layer_name == layerName && status == 1 && mb_mapObj[i].wms[ii].objLayer[iii].layer_queryable == 1){
- if (cnt_layer > 0) {
- str_layer += ",";
- }
- str_layer += layer_name;
- cnt_layer++;
- }
- }
- else if (type == "visible") {
- if (layer_name == layerName && status == 1) {
- if (cnt_layer > 0) {
- str_layer += ",";
- }
- str_layer += layer_name;
- cnt_layer++;
- }
- }
- for (var iiii = 0; iiii < arrayLayer.length; iiii++) {
- if (layer_name == arrayLayer[iiii] && layer_name != layerName) {
- if (cnt_layer > 0) {
- str_layer += ",";
- }
- str_layer += layer_name;
- cnt_layer++;
- }
- }
- }
- }
- }
- }
- }
- if (type == "visible") {
- mb_mapObj[myMapObj].layers[myWMS] = str_layer;
- var array_str_layer = str_layer.split(",");
- var str_styles = "";
- for (var cnt=0; cnt < array_str_layer.length; cnt++) {
- if (cnt > 0) {
- str_styles += ",";
- }
- str_styles += "";
- }
- mb_mapObj[myMapObj].styles[myWMS] = str_styles;
- }
- if (type == "querylayer") {
- mb_mapObj[myMapObj].querylayers[myWMS] = str_layer;
- }
-/*
- if(type == 'visible'){
- setSingleMapRequest(frameName,wms_title);
- }
-*/
-}
-
-function handleSelectedLayer_array(mapObj, array_wms, array_layer, type, status){
- //alert(mapObj+" / "+array_wms[0]+" / "+ array_layer[0]+" / "+ type+" / "+ status);
- var ind = getMapObjIndexByName(mapObj);
- for(var j=0; j<array_wms.length; j++){
- for(var i=0; i<mb_mapObj[ind].wms.length; i++){
- if(mb_mapObj[ind].wms[i].wms_id == array_wms[j]){
- var check = false;
- for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
- if(mb_mapObj[ind].wms[i].wms_id == array_wms[j] && mb_mapObj[ind].wms[i].objLayer[ii].layer_name == array_layer[j]){
- if(type == "visible"){
- mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status, 10);
- //alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
- check = true;
- }
- if(type == "querylayer" && (mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == "1" || mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == 1)){
- mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status, 10);
- }
- }
- }
- mb_restateLayers(mapObj, array_wms[j]);
- //alert('restate');
- /*
- * hier noch checken, welche wms sich geaendert haben und disctinct eine singleRequest aufrufen:
- */
- if(check === true){
-
- if(mb_mapObj[ind].wms[i].gui_wms_visible == 1){
- setSingleMapRequest(mapObj,mb_mapObj[ind].wms[i].wms_id);
- //alert('sSMR');
- }
- }
- }
- }
- }
-}
-
-function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
- var ind = getMapObjIndexByName(frameName);
- var width = parseInt(mb_mapObj[ind].width, 10);
- var height = parseInt(mb_mapObj[ind].height, 10);
- var arrayBBox = mb_mapObj[ind].extent.split(",");
- var minX = parseFloat(arrayBBox[0]);
- var minY = parseFloat(arrayBBox[1]);
- var maxX = parseFloat(arrayBBox[2]);
- var maxY = parseFloat(arrayBBox[3]);
- var deltaX = (maxX - minX)/width;
- var deltaY = (maxY - minY)/height;
- if(deltaX > 0){
- var roundx = 1/Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
- }
- else{
- var roundx = Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
- }
- if(deltaY > 0){
- var roundy = 1/Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
- }
- else{
- var roundy = Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
- }
- var xtentx = maxX - minX;
- var xtenty = maxY - minY;
- var posX = parseFloat(minX + (myClickX / width) * xtentx);
- var posY = parseFloat(maxY - (myClickY / height) * xtenty);
- posX = Math.round(posX * roundx)/roundx;
- posY = Math.round(posY * roundy)/roundy;
- return [posX, posY];
-}
-
-function makeRealWorld2mapPos(frameName,rw_posx, rw_posy){
- var ind = getMapObjIndexByName(frameName);
- var mpObj = mb_mapObj[ind];
- var arrayBBox = mpObj.extent.split(",");
- var minX = parseFloat(arrayBBox[0]);
- var minY = parseFloat(arrayBBox[1]);
- var maxX = parseFloat(arrayBBox[2]);
- var maxY = parseFloat(arrayBBox[3]);
- return [Math.round((rw_posx - minX)*mpObj.width/(maxX - minX)), Math.round((maxY - rw_posy)*mpObj.height/(maxY - minY))];
-}
-
-function mb_arrangeElement(frameName, elName, left, top) {
- if(frameName !== ""){
- window.frames[frameName].document.getElementById(elName).style.top = top;
- window.frames[frameName].document.getElementById(elName).style.left = left;
- }
- else{
- document.getElementById(elName).style.top = top;
- document.getElementById(elName).style.left = left;
- }
-}
-
-/***********************Drag & Drop***********************/
-function mb_getMousePos(e,fName){
-if(fName){
- if(ie){
- clickX = window.frames[fName].event.clientX;
- clickY = window.frames[fName].event.clientY;
- }
- else{
- clickX = e.pageX;
- clickY = e.pageY;
- }
- }
- else{
- if(ie){
- clickX = event.clientX;
- clickY = event.clientY;
- }
- else{
- clickX = e.pageX;
- clickY = e.pageY;
- }
- }
- var pos = [clickX,clickY];
- return pos;
-}
-// function for object-identification
-function getMapObjIndexByName(frameName){
- for(var i=0; i<mb_mapObj.length; i++){
- if(mb_mapObj[i].frameName == frameName){
- return i;
- }
- }
-}
-function getMapObjByName(frameName){
- for(var i=0; i<mb_mapObj.length; i++){
- if(mb_mapObj[i].frameName == frameName){
- return mb_mapObj[i];
- }
- }
- return false;
-}
-function mb_getLayerTitleByName(map_index, wms_index, myLayer_name){
- for(var i=0; i<mb_mapObj[map_index].wms[wms_index].objLayer.length; i++){
- if(mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_name == myLayer_name){
- return mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_title;
- }
- }
-}
-function getWMSIDByTitle(frameName,wms_title){
- var ind = getMapObjIndexByName(frameName);
- for(var i=0; i< mb_mapObj[ind].wms.length; i++){
- if(mb_mapObj[ind].wms[i].wms_title == wms_title){
- //return i;
- return mb_mapObj[ind].wms[i].wms_id;
- }
- }
-}
-function getWMSIndexByTitle(frameName,wms_title){
- var ind = getMapObjIndexByName(frameName);
- for(var i=0; i< mb_mapObj[ind].wms.length; i++){
- if(mb_mapObj[ind].wms[i].wms_title == wms_title){
- return i;
- }
- }
-}
-function getWMSIndexById(frameName,wms_id){
- var ind = getMapObjIndexByName(frameName);
- for(var i=0; i< mb_mapObj[ind].wms.length; i++){
- if(mb_mapObj[ind].wms[i].wms_id == wms_id){
- return i;
- }
- }
-}
-//scale
-function mb_getScale(frameName) {
-
- var myScale = eventBeforeGetScale.trigger({"frameName":frameName});
-/*
- for(var i=0; i<mb_GetScalePreFunctions.length; i++){
- var myScale = eval(mb_GetScalePreFunctions[i]);
- }
-*/
- if(typeof(myScale) == "number"){
- var Y_str = myScale;
- }
- else{
- var ind = getMapObjIndexByName(frameName);
- var arrayBBox = mb_mapObj[ind].extent.split(",");
- var xtenty = parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
- var scaleY = (xtenty / mb_mapObj[ind].height) *(mb_resolution * 100);
- if (scaleY<1){
- var Y_str = scaleY;
- }else{
- var Y_str = Math.round(scaleY);
- }
- }
- return Y_str;
-}
-
-function mb_repaintScale(frameName, x, y, scale){
- var ind = getMapObjIndexByName(frameName);
- if(x === null && y === null){
- var arrayBBox = mb_mapObj[ind].extent.split(",");
- x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
- y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
- }
- var minx = parseFloat(x) - (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
- var miny = parseFloat(y) - (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
- var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
- var maxy = parseFloat(y) + (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
- mb_repaint(frameName,minx, miny, maxx, maxy);
-}
-function mb_repaint(frameName,minx,miny,maxx,maxy){
- var ind = getMapObjIndexByName(frameName);
- mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
- setMapRequest(frameName);
-}
-/*
- * converts the extent of the mapobject so that the maximum extent will be displayed {@link mb_mapObj_const#calculateExtent}
- * use: mb_mapObj.calculateExtent
- * @deprecated
- *
- */
-function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
- var map = getMapObjByName(frameName);
- var extent = new Extent(minx,miny,maxx,maxy);
- map.calculateExtent(extent);
-}
-/*
- * @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){
- this.minx = parseFloat(minx);
- this.miny = parseFloat(miny);
- this.maxx = parseFloat(maxx);
- this.maxy = parseFloat(maxy);
- this.extentx = this.maxx - this.minx;
- this.extenty = this.maxy - this.miny;
- this.centerx = this.minx + this.extentx/2;
- this.centery = this.miny + this.extenty/2;
- return this;
-}
-
-function mb_showHighlight(frameName,x,y){
- var pos = makeRealWorld2mapPos(frameName,x, y);
- mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
- window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
-}
-function mb_hideHighlight(frameName){
- mb_arrangeElement(frameName,"highlight",-20, -20);
- mb_arrangeElement(frameName,"highlight",-20, -20);
- window.frames[frameName].document.getElementById("highlight").style.visibility = 'hidden';
-}
-function mb_permanentHighlight(frameName,x,y){
- var pos = makeRealWorld2mapPos(frameName,x, y);
- mb_arrangeElement(frameName,"permanent",pos[0]-7, pos[1]-7);
- window.frames[frameName].document.getElementById("permanent").style.visibility = 'visible';
-}
-// framename, commaseparated coordinates, commaseparated rgb values (color)
-//new: coords is array!
-function mb_markResult(frameName,geom,col){
- var x = "";
- var y = "";
- var tmp = [];
- var ind = getMapObjIndexByName(frameName);
- for(var i=0; i < geom.length; i++){
- if(i > 0){
- x += ":";
- y += ":";
- }
- tmp = geom[i].split(",");
- for(var ii=0; ii < tmp.length; ii+=2){
- var pos = makeRealWorld2mapPos(frameName,tmp[ii], tmp[ii+1]);
- if(ii>0){
- x += ",";
- y += ",";
- }
- x += pos[0];
- y += pos[1];
- }
- }
- var source = "<img src='../extensions/markResult.php?x=" + x + "&y=" + y + "&width=" + mb_mapObj[ind].width + "&height=" + mb_mapObj[ind].height + "&color="+col+"'>";
- //prompt("",source);
- writeTag(frameName,"markResult",source);
-}
-function mb_disableResult(frameName){
- writeTag(frameName,"markResult","");
-}
-
-function mb_registerGML(frameName,obj){
- var ind = getMapObjIndexByName(frameName);
- mb_mapObj[ind].geom = obj;
-}
-function mb_timestamp(){
- var d = new Date();
- var ts = Math.round(Date.parse(d)/1000);
- return ts;
-}
-function mb_getlayerposbyname(objInd,wmsInd,lname){
- var t = mb_mapObj[objInd].wms[wmsInd];
- for(var i=0; i < t.objLayer.length; i++){
- if(t.objLayer[i].layer_name == lname){
- return t.objLayer[i].layer_pos;
- }
- }
-}
-function mb_getLayerObjByName(fname,wms_id,layer_name){
- var ind = getMapObjIndexByName(fname);
- var wmsInd = getWMSIndexById(fname,wms_id);
- var t = mb_mapObj[ind].wms[wmsInd];
- for(var i=0; i < t.objLayer.length; i++){
- if(t.objLayer[i].layer_name == layer_name){
- return t.objLayer[i];
- }
- }
-}
-function mb_getchildsbyname(objInd,wmsInd,lname){
- var t = mb_mapObj[objInd].wms[wmsInd];
- var pos = mb_getlayerposbyname(objInd, wmsInd,lname);
- var l = [];
- l.name = [];
- l.title = [];
- l.legendurl = [];
- for(var i=0; i < t.objLayer.length; i++){
- if(t.objLayer[i].layer_parent == pos){
- l.name[l.name.length] = t.objLayer[i].layer_name;
- l.title[l.title.length] = t.objLayer[i].layer_title;
- if(t.objLayer[i].layer_style.length>0){
- l.legendurl[l.legendurl.length] = t.objLayer[i].layer_style[0].legendurl;
- }else{
- l.legendurl[l.legendurl.length] = 0 ;
- }
- }
- }
- if(l.name.length > 0){
- return l;
- }
- else{
- return false;
- }
-}
-/*
- ***************************************************************************************
- * button handling
- ***************************************************************************************
- */
-
-var mb_button = [];
-
-function mb_regButton_frame(wii, frameName, param){
- var ind = mb_button.length;
- mb_button[ind] = new mb_conButton(wii, ind);
- if (frameName === null) {
- if (param === null) {
- eval(wii+"("+ind+")");
- }
- else {
- eval(wii+"("+ind+", "+param+")");
- }
- }
- else if (param === null) {
- eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
- }
- else {
- eval("window.frames['" + frameName + "']."+wii+"("+ind+", "+param+")");
- }
- mb_button[ind].prev = mb_button[ind].src;
- mb_button[ind].src = mb_button[ind].img_off;
- mb_button[ind].onmouseover = function () {
- mb_button_over(ind);
- };
- mb_button[ind].onmouseout = function(){
- mb_button_out(ind);
- };
- mb_button[ind].onclick = function(){
- mb_button_click(ind);
- };
- if (frameName === null) {
- mb_button[ind].frameName = "";
- }
- else {
- mb_button[ind].frameName = frameName;
- }
-}
-
-function mb_regButton(wii){
- mb_regButton_frame(wii, null, null);
-}
-
-function mb_conButton(wii, ind){
- this.wii = wii;
- return true;
-}
-function mb_button_over(ind){
- if(mb_button[ind].status === 0){
- mb_button[ind].prev = mb_button[ind].src;
- mb_button[ind].src = mb_button[ind].img_over;
- }
-}
-function mb_button_out(ind){
- mb_button[ind].src = mb_button[ind].prev;
-}
-function mb_button_click(ind){
- var mbStatus = mb_button[ind].status;
- if(mbStatus === 0){
- mb_disableButton(mb_button[ind].elName);
- mb_button[ind].prev = mb_button[ind].img_on;
- mb_button[ind].src = mb_button[ind].img_on;
- mb_button[ind].status = 1;
- if (mb_button[ind].frameName !== "") {
- window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
- }
- else {
- document.getElementById(mb_button[ind].elName).go();
- }
- }
- else{
- mb_button[ind].prev = mb_button[ind].img_off;
- mb_button[ind].src = mb_button[ind].img_off;
- mb_button[ind].status = 0;
- if (mb_button[ind].frameName !== "") {
- window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
- }
- else {
- document.getElementById(mb_button[ind].elName).stop();
- }
- }
-}
-function mb_disableButton(elName){
- for(var i=0; i<mb_button.length; i++){
- if(mb_button[i].elName != elName && mb_button[i].status == 1){
- mb_button[i].status = 0;
- if (mb_button[i].frameName !== "") {
- window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
- window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
- }
- else {
- document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
- document.getElementById(mb_button[i].elName).stop();
- }
- return true;
-
- }
- }
-}
-function mb_disableThisButton(elName){
- for(var i=0; i<mb_button.length; i++){
- if(mb_button[i].elName == elName && mb_button[i].status == 1){
- //alert(mb_button[i].elName);
- mb_button[i].status = 0;
- if (mb_button[i].frameName !== "") {
- window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
- window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
- }
- else {
- document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
- document.getElementById(mb_button[i].elName).stop();
- }
- return true;
-
- }
- }
-}
-function updateButtonTooltips(obj) {
-/*
- * the buttons are only initialized on mouseover!
- * So when localizing, not all buttons may have been registered
- *
- for(var i=0; i<mb_button.length; i++){
-// console.log("button %i", i);
- for(var j=0; j<obj.length; j++){
- if (mb_button[i].elName == obj[j].id) {
-// console.log("%s %s", mb_button[i].elName, obj[j].id);
- if (mb_button[i].frameName !== "") {
- window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).title = obj[j].title;
- }
- else {
- document.getElementById(mb_button[i].elName).title = obj[j].title;
- }
- }
- }
- }
-*/
-
- // an alternative, fixes above error,
- // but this one only changes those in the main frame
- var imageArray = document.getElementsByTagName("img");
- for (var i = 0; i < imageArray.length; i++) {
- for(var j=0; j<obj.length; j++){
- if (imageArray[i].id == obj[j].id) {
- document.getElementById(imageArray[i].id).title = obj[j].title;
- }
- }
- }
-}
-
-function mb_localizeButtons(){
- mb_ajax_json("../php/mod_button_tooltips.php", function(obj, status){
- updateButtonTooltips(obj);
- });
-}
-
-eventLocalize.register(function () {
- mb_localizeButtons();
-});
-
-eventInit.register(function () {
- mb_localizeButtons();
-});
-
-
-/*
- ***************************************************************************************
- * miscellaneous functions
- ***************************************************************************************
- */
-
-function cloneObject(obj) {
- if (typeof obj !== 'object' || obj === null) {
- return obj;
- }
- var c = obj instanceof Array ? [] : {};
- for (var i in obj) {
- var prop = obj[i];
- if (typeof prop == 'object') {
- if (prop instanceof Array) {
- c[i] = [];
- for (var j = 0; j < prop.length; j++) {
- if (typeof prop[j] != 'object') {
- c[i].push(prop[j]);
- } else {
- c[i].push(cloneObject(prop[j]));
- }
- }
- } else {
- c[i] = cloneObject(prop);
- }
- } else {
- c[i] = prop;
- }
- }
- return c;
-}
-
-
-/*
- ***************************************************************************************
- * deprecated functions
- ***************************************************************************************
- */
-
-// only used in mod_perimeter.php
-// previously used in mod_initWmc.php, mod_digitize_tab.php, mod_geometryArray.js
-function mb_checkTag(frameName, tagName, elementId, appendAtTagName, attributes){
- var oldElement;
- var newElement;
- var prefix;
- if(frameName && frameName !== ""){
- prefix = window.frames[frameName].document;
- }
- else if(!frameName || frameName === ""){
- prefix = document;
- }
- oldElement = prefix.getElementById(elementId);
- if (oldElement === null) {
- newElement = prefix.createElement(tagName);
- newElement = prefix.getElementsByTagName(appendAtTagName)[0].appendChild(newElement);
- }
- else {
- if (oldElement.nodeName.toLowerCase() == tagName.toLowerCase()) {
- for (var i=0; i<attributes.length; i++) {
- oldElement.setAttribute(attributes[i][0], attributes[i][1]);
- }
- return oldElement;
- }
- else {
- return false;
- }
- }
- var newElementAttributeNode = document.createAttribute("id");
- newElementAttributeNode.value = elementId;
- newElement.setAttributeNode(newElementAttributeNode);
- for (var i=0; i<attributes.length; i++) {
- newElement.setAttribute(attributes[i][0], attributes[i][1]);
- }
- return newElement;
-}
\ No newline at end of file
Modified: branches/beck_dev/mapbender/http/javascripts/map.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/map.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -72,33 +72,33 @@
echo "var mb_security_proxy = '" . MB_SECURITY_PROXY . "';";
//
-// Load JavaScript libraries
+// Load external JavaScript libraries
//
require_once(dirname(__FILE__) . "/../extensions/jquery.js");
+require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
+
+//
+// Load internal JavaScript libraries
+//
require_once(dirname(__FILE__) . "/../../lib/map_obj.js");
require_once(dirname(__FILE__) . "/../../lib/exception.js");
require_once(dirname(__FILE__) . "/../../lib/ajax.js");
require_once(dirname(__FILE__) . "/../../lib/div.js");
require_once(dirname(__FILE__) . "/../../lib/list.js");
-require_once(dirname(__FILE__) . "/../javascripts/map.js");
-require_once(dirname(__FILE__) . "/../javascripts/point.js");
+require_once(dirname(__FILE__) . "/../../lib/map.js");
+require_once(dirname(__FILE__) . "/../../lib/point.js");
require_once(dirname(__FILE__) . "/../../lib/wms.js");
-require_once(dirname(__FILE__) . "/../javascripts/wfs_obj.js");
-require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
-require_once(dirname(__FILE__) . "/../javascripts/style.js");
+require_once(dirname(__FILE__) . "/../../lib/wfs_obj.js");
+require_once(dirname(__FILE__) . "/../../lib/style.js");
//
// Load WMS
//
-$sql = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id = $1 ORDER BY gui_wms_position";
-$v = array($gui_id);
-$t = array('s');
-$res = db_prep_query($sql, $v, $t);
+$wmsArray = wms::selectMyWmsByApplication($gui_id);
-while($row = db_fetch_array($res)) {
- $mywms = new wms();
- $mywms->createObjFromDB($gui_id, $row["fkey_wms_id"]);
- $mywms->createJsObjFromWMS();
+for ($i = 0; $i < count($wmsArray); $i++) {
+ $currentWms = $wmsArray[$i];
+ $currentWms->createJsObjFromWMS();
}
//
@@ -147,7 +147,4 @@
}
}
}
-
-
-
?>
\ No newline at end of file
Modified: branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/mod_loadwmc.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -66,6 +66,12 @@
$jsArray = $wmc->toJavaScript();
// }
echo implode("", $jsArray);
+
+ // test wmc from app
+ $newWmc = new wmc();
+ $newWmc->createFromApplication($_SESSION["mb_user_gui"]);
+
+
}
else {
echo "var e = new Mb_notice('mod_loadwmc: load_wmc_session: error parsing wmc');";
Deleted: branches/beck_dev/mapbender/http/javascripts/point.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/point.js 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/point.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,192 +0,0 @@
-/*
-* $Id$
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
-*/
-//http://www.mapbender.org/index.php/point.js
-
-/**
- * @class A class representing a two-dimensional point.
- *
- * @constructor
- * @param {Float} x x value of the {@link Point}
- * @param {Float} y y value of the {@link Point}
- */
- function Point(x, y, z){
- /**
- * x value of the {@link Point}
- *
- * @type Float
- */
-// this.x = parseFloat(x);
- this.x = x;
- /**
- * y value of the {@link Point}
- *
- * @type Float
- */
-// this.y = parseFloat(y);
- this.y = y;
-
- this.z = z;
-
-}
-/**
- * computes the distance between a {@link Point} p and this {@link Point}
- *
- * @param {Point} p the distance between this {@link Point} and the {@link Point} p is computed.
- * @return {Float} the distance between the two {@link Point} objects.
- */
-Point.prototype.dist = function(p){
- return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
-};
-/**
- * checks if the coordinates of this {@link Point} match the coordinates of a {@link Point} p
- *
- * @param {Point} p
- * @return {Boolean} true if the two points are equal; elso false
- */
-Point.prototype.equals = function(p){
- if (this.x == p.x && this.y == p.y) {return true;}
- return false;
-};
-/**
- * subtracts a {@link Point} p from this {@link Point}
- *
- * @param {Point} p
- * @return a new {@link Point} with the difference of the two points
- */
-Point.prototype.minus = function(p){
- return new Point(this.x-p.x, this.y-p.y);
-};
-/**
- * adds this {@link Point} to a {@link Point} p
- *
- * @param {Point} p
- * @return a new {@link Point} with the sum of the two points
- */
-Point.prototype.plus = function(p){
- return new Point(this.x+p.x, this.y+p.y);
-};
-/**
- * divides this {@link Point} by a scalar c
- *
- * @param {Float} c divisor
- * @return a new {@link Point} divided by c
- */
-Point.prototype.dividedBy = function(c){
- if (c !== 0) {
- return new Point(this.x/c, this.y/c);
- }
- var e = new Mb_exception("Point.dividedBy: Division by zero");
- return false;
-};
-/**
- * multiplies this {@link Point} by a scalar c
- *
- * @param {Float} c factor
- * @return a new {@link Point} multiplied by c
- */
-Point.prototype.times = function(c){
- return new Point(this.x*c, this.y*c);
-};
-/**
- * rounds the coordinates to numOfDigits digits
- *
- * @param numOfDigits the coordinate will be rounded to numOfDigits digits
- * @return a new {@link Point} rounded to numOfDigits digits
- * @type Point
- */
-Point.prototype.round = function(numOfDigits){
- return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
-};
-/**
- * @returns a {String} representation of this Point
- * @type String
- */
-Point.prototype.toString = function(){
- if (typeof(this.z == "undefined")) {
- return "[" + this.x + ", " + this.y + "]";
- }
- else {
- return "[" + this.x + ", " + this.y + ", " + this.z + "]";
- }
-};
-
-
-//------------------------------------------------------------------------
-// possible improvement: point has flag: map OR real. additional functions: toReal, toMap
-/**
- * @ignore
- */
-function mapToReal(frameName, aPoint){
- var v;
- if (typeof(mb_mapObj) == 'object') {
- v = makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
- }
- else {
- if (typeof(parent.mb_mapObj) == 'object') {
- v = parent.makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
- }
- else {
- alert('where am i?');
- }
- }
- return new Point(v[0], v[1]);
-}
-/**
- * @ignore
- */
-function realToMap(frameName, aPoint) {
- var v;
- if (typeof(mb_mapObj) == 'object') {
- v = makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
- }
- else if (typeof(parent.mb_mapObj) == 'object') {
- v = parent.makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
- }
- else {
- var e = new Mb_exception('Point.realToMap:where am i?');
- }
- return new Point(v[0], v[1]);
-}
-/**
- * @ignore
- */
-function mb_calcExtent(frameName, min, max) {
- var ind;
- if (typeof(mb_mapObj) == 'object') {
- ind = getMapObjIndexByName(frameName);
- }
- else if (typeof(parent.mb_mapObj) == 'object') {
- ind = parent.getMapObjIndexByName(frameName);
- }
- else {
- var e = new Mb_exception('Point.mb_calcExtent: function getMapObjIndexByName not found');
- }
- var extent = max.minus(min);
- var center = extent.dividedBy(2).plus(min);
-
- var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
- var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
- var relation_bbox_x = extent.x / extent.y;
-
- var new_min;
- var new_max;
-
- if(relation_bbox_x <= relation_px_x){
- new_min = new Point(center.x - relation_px_x * extent.y / 2, min.y);
- new_max = new Point(center.x + relation_px_x * extent.y / 2, max.y);
- }
- else if(relation_bbox_x > relation_px_x){
- 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_min.x +","+ new_min.y +","+ new_max.x +","+ new_max.y;
-}
-/**
- * @ignore
- */
-function roundToDigits(aFloat, numberOfDigits) {
- return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits, 10)))/Math.pow(10, parseInt(numberOfDigits, 10));
-}
Deleted: branches/beck_dev/mapbender/http/javascripts/style.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/style.js 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/style.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,54 +0,0 @@
-/**
- * creates a style tag in the head of the document.
- *
- */
-var StyleTag = function() {
-
- /**
- * Creates the style tag in the head of the document. Something like a constructor.
- *
- */
- var createStyleTag = function() {
- // TODO: Internet Explorer routine seems a little buggy
- if (top.ie) {
- // create a Style Sheet object (IE only)
- //styleSheetObj=document.createStyleSheet();
- // get the DOM node of the style sheet object, set the type
- //styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
- //styleObj.setAttribute("type","text/css");
-
- // alternative way for IE: take existing styleSheet with index 0 instead of creating a new one
- styleSheetObj=document.styleSheets[0];
- }
- else {
- // create the style node, set the style
- styleObj=document.createElement("style");
- styleObj.setAttribute("type","text/css");
- // append the node to the head
- document.getElementsByTagName("head")[0].appendChild(styleObj);
- }
- };
-
- /**
- * Adds a class className with the CSS in cssString
- */
- this.addClass = function(className,cssString) {
- // TODO: Internet Explorer routine seems a little buggy
- if (top.ie) {
- //add new style declaration to chosen styleSheet
- var cssRules = cssString.split(";");
- for (i=0; i<cssRules.length-1; i++){
- styleSheetObj.addRule("."+className,cssRules[i]);
- }
- }
- else {
- // insert the content via createTextNode
- styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));
- }
- };
-
- var styleObj;
- var styleSheetObj; //IE only...
-
- createStyleTag();
-};
\ No newline at end of file
Deleted: branches/beck_dev/mapbender/http/javascripts/wfs_obj.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/wfs_obj.js 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/javascripts/wfs_obj.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,75 +0,0 @@
-//$Id$
-//$Header: /cvsroot/mapbender/mapbender/http/javascripts/wfs_obj.js,v 1.3 2005/09/13 14:38:11 bjoern_heuser Exp $
-//global variables
-var wfs = [];
-var wfs_featuretype_count = 0;
-var wfs_element_count = 0;
-//list of all wms-objects
-function add_wfs(
- wfs_id,
- wfs_version,
- wfs_title,
- wfs_abstract,
- wfs_getcapabilities,
- wfs_describefeaturetype){
- wfs[wfs.length] = new wfs_const(
- wfs_id,
- wfs_version,
- wfs_title,
- wfs_abstract,
- wfs_getcapabilities,
- wfs_describefeaturetype);
- //wfs_featuretype[wfs.length - 1] = [];
-}
-//the wms constructor
-function wfs_const(
- wfs_id,
- wfs_version,
- wfs_title,
- wfs_abstract,
- wfs_getcapabilities,
- wfs_describefeaturetype){
-
- this.wfs_id = wfs_id;
- this.wfs_version = wfs_version;
- this.wfs_title = wfs_title;
- this.wfs_abstract = wfs_abstract;
- this.wfs_getcapabilities = wfs_getcapabilities;
- this.wfs_describefeaturetype = wfs_describefeaturetype;
-
- this.wfs_featuretype = [];
- //alert(wfs_id + " , " +wfs_title + " , " +wfs_abstract + " , " +wfs_getcapabilities + " , " +wfs_describefeaturetype);
-}
-//featuretype
-function wfs_add_featuretype(
- featuretype_name,
- featuretype_title,
- featuretype_srs,
- featuretype_geomtype){
-
- wfs[wfs.length-1].wfs_featuretype[wfs[wfs.length-1].wfs_featuretype.length] = new featuretype(
- featuretype_name,
- featuretype_title,
- featuretype_srs,
- featuretype_geomtype);
-//alert(featuretype_name + " , " +featuretype_title + " , " +featuretype_srs + " , " +featuretype_geomtype);
-}
-function featuretype(
- featuretype_name,
- featuretype_title,
- featuretype_srs,
- featuretype_geomtype){
- this.featuretype_name = featuretype_name;
- this.featuretype_title = featuretype_title;
- this.featuretype_srs = featuretype_srs;
- this.featuretype_geomtype = featuretype_geomtype;
- this.element = [];
- wfs_featuretype_count++;
-}
-//elements
-function wfs_add_featuretype_element(element_name, element_type, element_count, featuretype_count){
- wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count] = [];
- wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count].name = element_name;
- wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count].type = element_type;
- //alert(element_name +" , "+element_type);
-}
Deleted: branches/beck_dev/mapbender/http/php/mb_listWMCs.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mb_listWMCs.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/php/mb_listWMCs.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,201 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mb_listWMCs.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.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__) . "/../classes/class_administration.php");
-require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
-
-$gui_id = $_SESSION["mb_user_gui"];
-$user_id = $_SESSION["mb_user_id"];
-
-$action = $_GET["action"];
-$wmcId = $_GET["wmc_id"];
-
-$delWmcId = $_POST["del_wmc_id"];
-$clientFilename = $_FILES['local_wmc_filename']['tmp_name'];
-
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
- <head>
- <meta http-equiv="cache-control" content="no-cache">
- <meta http-equiv="pragma" content="no-cache">
- <meta http-equiv="expires" content="0">
- <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET;?>">
- <title>Select web map contect document from list</title>
- </head>
- <body>
- <form name='delete_wmc' action='<?php echo $self; ?>' method='POST'>
- <input type='hidden' id='delete_wmc' name='del_wmc_id' value ='' >
- </form>
-
-<?php
-function mb_listWMCs($wmcIdArray, $form_target){
- $display = "<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;background-color: White;'><font align='left' color='#000000'>load WMC from list</font></h2>";
- $display .= "<table width='90%' style='font-family: Arial, Helvetica, sans-serif;font-size : 12px;color: #808080;' border='1' cellpadding='3' rules='rows'><tr style='background-color:#F0F0F0;' width='80px'><td ><b>WMC name</b></td><td><b>last update</b></td><td colspan=5></td></tr>";
-
- if (count($wmcIdArray) > 0) {
- $v = array();
- $t = array();
-
- $wmcIdList = "";
- for ($i = 0; $i < count($wmcIdArray); $i++){
- if ($i > 0){
- $wmcIdList .= ",";
- }
- $wmcIdList .= "$".($i+1);
- array_push($v, $wmcIdArray[$i]);
- array_push($t, 's');
- }
- $sql_list_wmcs = "SELECT DISTINCT wmc_id, wmc_title, wmc_timestamp FROM mb_user_wmc ";
- $sql_list_wmcs .= "WHERE wmc_id IN (" . $wmcIdList . ") ";
- $sql_list_wmcs .= "ORDER BY wmc_timestamp DESC";
-
- $res_list_wmcs = db_prep_query($sql_list_wmcs, $v, $t);
- while($row = db_fetch_array($res_list_wmcs)){
- $this_id = $row["wmc_id"];
- $this_title = $row["wmc_title"];
- $this_timestamp = date("M d Y H:i:s", $row["wmc_timestamp"]);
-
- $display .= "<tr onmouseover='this.style.backgroundColor = \"#F08080\"' onmouseout='this.style.backgroundColor = \"#ffffff\"'>";
- $display .= "<td>".$this_title."</td>";
- $display .= "<td>".$this_timestamp. "</td>";
- $display .= "<td><a href=\"" . $form_target . "&action=load&wmc_id=".$this_id."\"><img src=\"../img/button_gray/wmc_load.png\" title=\"load this WMC\" border=0></a></td>";
- $display .= "<td><a href=\"" . $form_target . "&action=merge&wmc_id=".$this_id."\"><img src=\"../img/button_gray/wmc_merge.png\" title=\"merge WMC\" border=0></a></td>";
- $display .= "<td><a href=\"" . $form_target . "&action=append&wmc_id=".$this_id."\"><img src=\"../img/button_gray/wmc_append.png\" title=\"append WMC\" border=0></a></td>";
- $display .= "<td><a href='../javascripts/mod_displayWmc.php?wmc_id=".$this_id."' target = '_blank'><img src=\"../img/button_gray/wmc_xml.png\" title=\"display WMC XML\" border=0></a></td>";
- $display .= "<td><a href=\"" . $form_target . "&action=delete&wmc_id=".$this_id."\"><img src=\"../img/button_gray/del.png\" title=\"delete this WMC\" border=0></a></td>";
- $display .= "</tr>";
- }
- }
- else{
- $display .= "<tr><td>There are no WMCs availiable</td></tr>";
- }
- $display .= "</table>";
-
- return $display;
-}
-
-function getTarget($gui_id) {
- $sql = "SELECT e_requires, e_target FROM gui_element WHERE e_id = 'loadwmc' AND fkey_gui_id = $1";
- $v = array($gui_id);
- $t = array("s");
- $res = db_prep_query($sql, $v, $t);
- $cnt = 0;
- while($row = db_fetch_array($res)){
- $e_target = $row["e_target"];
- $e_require = $row["e_requires"];
- $cnt++;
- }
- if ($cnt > 1) {
- $e = new mb_exception("listWMCs: e_id 'loadwmc' not unique in GUI '" . $gui_id . "'!");
- }
-
- $targetArray = explode(",", $e_target);
- if (in_array('mapframe1', $targetArray)) {
- return 'mapframe1';
- }
- else {
- return trim($targetArray[0]);
- }
-}
-
-function loadFile($filename) {
- $handle = fopen($filename, "r");
- $cnt = 0;
- while (!feof($handle)) {
- $buffer .= fgets($handle, 4096);
- }
- fclose ($handle);
- return $buffer;
-}
-
-$admin = new administration();
-$wmcIdArray = $admin->getWmcByOwner($user_id);
-
-// wmc is being deleted
-if (!empty($delWmcId)) {
- $result = $admin->deleteWmc($delWmcId, $user_id);
- if (!$result) {
- echo "<script language='javascript'>";
- echo "alert('WMC could not be deleted!');";
- echo "</script>";
- }
-}
-// wmc is being loaded from file
-elseif ($clientFilename) {
- $serverFilename = "../tmp/wmc" . time() . ".xml";
- copy($clientFilename, $serverFilename);
-
- $wmc = new wmc();
- $wmc->createObjFromWMC_xml(loadFile($serverFilename));
-
- $mytarget = getTarget($gui_id);
- $js = $wmc->createJsObjFromWMC("window.opener.", $mytarget, "load");
- echo "<script language='javascript'>";
- echo $js;
- if ($wmc->getTitle()) {
- $title = "'" . $wmc->getTitle() . "' ";
- }
- echo "alert(\"WMC " . $title . ": load successful.\");\n";
- echo "window.close();";
- echo "</script>";
-}
-
-// load a WMC from file
-?>
-<h2 style='font-family: Arial, Helvetica, sans-serif; color: #808080;background-color: White;'><font align='left' color='#000000'>load WMC from file</font></h2>
-<form enctype="multipart/form-data" action="<?php echo $self;?>" method=POST target="_self">
-<input type='file' name='local_wmc_filename'>
-<input type='submit' value='load'>
-</form>
-<?php
-
-// load a WMC from list
-echo mb_listWMCs($wmcIdArray, $self);
-
-if ($wmcId && in_array($wmcId, $wmcIdArray)){
- if ($action == "delete") {
- echo "<script language='javascript'>";
- echo "value = confirm('Do you really want to delete this document?');";
- echo "if (value == true) {";
- echo "document.delete_wmc.del_wmc_id.value = '" . $wmcId . "';";
- echo "document.delete_wmc.submit();";
- echo "}";
- echo "</script>";
- }
- else if ($action == "append" || $action == "merge" || $action == "load") {
- $mytarget = getTarget($gui_id);
-
- $wmc = new wmc();
- $wmc->createObjFromWMC_id($wmcId);
- $js = $wmc->createJsObjFromWMC("window.opener.", $mytarget, $action);
-
- echo "<script language='javascript'>";
- echo $js;
- if ($wmc->getTitle()) {
- $title = "'" . $wmc->getTitle() . "' ";
- }
- echo "alert(\"WMC " . $title . ": " . $action . " successful.\");\n";
- echo "window.close();";
- echo "</script>";
- }
-}
-?>
-</body>
-</html>
\ No newline at end of file
Deleted: branches/beck_dev/mapbender/http/php/mod_createJSObjFromDB.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_createJSObjFromDB.php 2008-05-28 14:31:38 UTC (rev 2475)
+++ branches/beck_dev/mapbender/http/php/mod_createJSObjFromDB.php 2008-05-28 15:03:41 UTC (rev 2476)
@@ -1,33 +0,0 @@
-<?php
-# $Id$
-# http://www.mapbender.org/index.php/mod_createJSObjectFromDB.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.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-require_once(dirname(__FILE__)."/../classes/class_wms.php");
-
-$sql = "SELECT fkey_wms_id FROM gui_wms WHERE fkey_gui_id = $1 ORDER BY gui_wms_position";
-$v = array($_SESSION["mb_user_gui"]);
-$t = array('s');
-$res = db_prep_query($sql,$v,$t);
-
-while($row = db_fetch_array($res)){
- $mywms = new wms();
- $mywms->createObjFromDB($_SESSION["mb_user_gui"],$row["fkey_wms_id"]);
- $mywms->createJsObjFromWMS();
-}
-?>
\ No newline at end of file
Copied: branches/beck_dev/mapbender/lib/map.js (from rev 2452, branches/beck_dev/mapbender/http/javascripts/map.js)
===================================================================
--- branches/beck_dev/mapbender/lib/map.js (rev 0)
+++ branches/beck_dev/mapbender/lib/map.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -0,0 +1,1200 @@
+var ie = document.all?1:0;
+var n6 = document.getElementById&&!document.all?1:0;
+var n4 = document.layers?1:0;
+
+var mb_mapObj = [];
+var mb_fiWin = null;
+var mb_panActive = false;
+var clickX;
+var clickY;
+var mb_start_x = 0;
+var mb_start_y = 0;
+var mb_end_x = 0;
+var mb_end_y = 0;
+var mb_offset_top = 0;
+var mb_offset_right = 0;
+var mb_offset_bottom = 0;
+var mb_offset_left = 0;
+var mb_log = null;
+
+/**
+ * @deprecated
+ */
+function mb_execloadWmsSubFunctions(){
+ eventAfterLoadWMS.trigger();
+}
+
+function mb_execWfsReadSubFunctions(geom) {
+ for(var i=0; i<mb_WfsReadSubFunctions.length; i++){
+ mb_WfsReadSubFunctions[i](geom);
+ }
+}
+
+function mb_execWfsWriteSubFunctions() {
+ for(var i=0; i<mb_WfsWriteSubFunctions.length; i++){
+ mb_WfsWriteSubFunctions[i]();
+ }
+}
+
+function mb_setWmcExtensionData(anArray) {
+ for (var i in anArray) {
+ if (typeof(anArray[i]) != "undefined") {
+ currentWmcExtensionData[i] = anArray[i];
+ }
+ }
+}
+
+function mb_getWmcExtensionData(arrayKey) {
+ for (var i in restoredWmcExtensionData) {
+ if (arrayKey == i) {
+ return restoredWmcExtensionData[i];
+ }
+ }
+ var e = new Mb_warning("mb_getWmcExtensionData: "+arrayKey+" not found. Maybe this GUI does not allow loading or saving WMC documents from/to the session");
+ return null;
+}
+
+// transparent GIF
+var mb_trans = new Image();
+mb_trans.src = "../img/transparent.gif";
+
+
+/**
+ * Called in index.php on body onload
+ */
+function init() {
+ // creates the map objects (mapframe1, overview...)
+ eventInitMap.trigger();
+
+ // initialisation
+ eventInit.trigger();
+
+ // performs a map request for each map frame
+ for(var i=0; i<mb_mapObj.length; i++){
+ setMapRequest(mb_mapObj[i].frameName);
+ }
+}
+
+function mb_registerMapObj(frameName, elementName,wms_index,width, height){
+ mb_mapObj.push(new mb_mapObj_const(frameName, elementName, width, height, wms_index));
+}
+
+/*
+ * get the conjunction character of an URL
+ * @param {String} onlineresource
+ * @return the character & or ?
+ * @type String
+ */
+function mb_getConjunctionCharacter(onlineresource){
+ var conChar;
+ if(onlineresource.indexOf("?") > -1){
+ if(onlineresource.charAt(onlineresource.length-1) == "?"){
+ conChar = "";
+ }else if(onlineresource.charAt(onlineresource.length-1) == "&"){
+ conChar = "";
+ }else{
+ conChar = "&";
+ }
+ }
+ if(onlineresource.indexOf("?") == -1){
+ conChar = "?";
+ }
+ return conChar;
+}
+
+
+function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
+ if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
+ var changed = false;
+ var i;
+ var result;
+ if (fromIndex > toIndex) {
+ for (i = fromIndex; i > toIndex ; i--) {
+ result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
+ if (result === true) {
+ changed = true;
+ }
+ }
+ }
+ else {
+ for (i = fromIndex; i < toIndex ; i++) {
+ result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
+ if (result === true) {
+ changed = true;
+ }
+ }
+ }
+ return changed;
+ }
+ else {
+ return false;
+ }
+}
+
+function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
+ if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
+ upper = mb_mapObj[mapObj_ind].wms[indexA];
+ mb_mapObj[mapObj_ind].wms[indexA] = mb_mapObj[mapObj_ind].wms[indexB];
+ mb_mapObj[mapObj_ind].wms[indexB] = upper;
+ var upperLayers = mb_mapObj[mapObj_ind].layers[indexA];
+ var upperStyles = mb_mapObj[mapObj_ind].styles[indexA];
+ var upperQuerylayers = mb_mapObj[mapObj_ind].querylayers[indexA];
+ mb_mapObj[mapObj_ind].layers[indexA] = mb_mapObj[mapObj_ind].layers[indexB];
+ mb_mapObj[mapObj_ind].styles[indexA] = mb_mapObj[mapObj_ind].styles[indexB];
+ mb_mapObj[mapObj_ind].querylayers[indexA] = mb_mapObj[mapObj_ind].querylayers[indexB];
+ mb_mapObj[mapObj_ind].layers[indexB] = upperLayers;
+ mb_mapObj[mapObj_ind].styles[indexB] = upperStyles;
+ mb_mapObj[mapObj_ind].querylayers[indexB] = upperQuerylayers;
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
+function mb_mapObjaddWMS(obj){
+ var cnt_layers = 0;
+ var cnt_querylayers = 0;
+ var styles = "";
+ var layers = "";
+ var querylayers = "";
+ var ind = getMapObjIndexByName(obj);
+ //is the id valid?
+ for( var i=0; i<(wms.length-1); i++){
+ if(parseInt(wms[i].wms_id, 10) >= parseInt(wms[wms.length-1].wms_id, 10)){
+ wms[wms.length-1].wms_id = parseInt(mb_mapObj[ind].wms[i].wms_id, 10) + 1;
+ }
+ }
+ mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
+ mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
+ mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
+ mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;
+ mb_execloadWmsSubFunctions();
+ return true;
+}
+function mb_mapObjremoveWMS(objind,wmsind){
+ var wms_ID = null;
+ var i;
+ var new_wmsarray = [];
+ var new_layerarray = [];
+ var new_querylayerarray = [];
+ var new_stylesarray = [];
+ var new_mapURLarray = [];
+
+ for (i=0;i<mb_mapObj[objind].wms.length; i++){
+ if(i != wmsind){
+ new_wmsarray[new_wmsarray.length] = mb_mapObj[objind].wms[i];
+ new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
+ new_querylayerarray[new_querylayerarray.length] = mb_mapObj[objind].querylayers[i];
+ new_stylesarray[new_stylesarray.length] = mb_mapObj[objind].styles[i];
+ new_mapURLarray[new_mapURLarray.length] = mb_mapObj[objind].mapURL[i];
+ }
+ else {
+ wms_ID = mb_mapObj[objind].wms[i].wms_id;
+ }
+ }
+ mb_mapObj[objind].wms = new_wmsarray;
+ mb_mapObj[objind].layers = new_layerarray;
+ mb_mapObj[objind].querylayers = new_querylayerarray;
+ mb_mapObj[objind].styles = new_stylesarray;
+ mb_mapObj[objind].mapURL = new_mapURLarray;
+
+ var another_new_wmsarray = [];
+ for (i=0;i<wms.length; i++){
+ if(wms[i].wms_id != wms_ID){
+ another_new_wmsarray[another_new_wmsarray.length] = wms[i];
+ }
+ }
+ wms = another_new_wmsarray;
+}
+function setExtent(width,height,epsg){
+ for(var i=0; i < wms[0].gui_epsg.length; i++){
+ if(wms[0].gui_epsg[i] == epsg){
+ var bbox_minx = parseFloat(wms[0].gui_minx[i]);
+ var bbox_miny = parseFloat(wms[0].gui_miny[i]);
+ var bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
+ var bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
+
+ var extenty = bbox_maxy - bbox_miny;
+ var extentx = bbox_maxx - bbox_minx;
+
+ var relation_px_x = width / height;
+ var relation_px_y = height / width;
+ var relation_bbox_x = extentx / extenty;
+ var centerx = bbox_minx + (extentx/2);
+ var centery = bbox_miny + (extenty/2);
+ if(relation_bbox_x <= relation_px_x){
+ bbox_minx = centerx - relation_px_x * extenty / 2;
+ bbox_maxx = centerx + relation_px_x * extenty / 2;
+ }
+
+ if(relation_bbox_x > relation_px_x){
+ bbox_miny = centery - relation_px_y * extentx / 2;
+ bbox_maxy = centery + relation_px_y * extentx / 2;
+ }
+ return bbox_minx +","+ bbox_miny +","+ bbox_maxx +","+ bbox_maxy;
+ }
+ }
+}
+function setMapRequest(frameName){
+ var functionName = 'setMapRequest';
+
+ var ret = eventBeforeMapRequest.trigger({frameName:frameName}, "AND");
+ if (ret === false) {
+ return true;
+ }
+
+ var ts = mb_timestamp();
+ var myMapIds = [];
+ for (var i=0; i < mb_mapObj.length; i++){
+ var currentMapObject = mb_mapObj[i];
+ if (currentMapObject.frameName != frameName) {
+ continue;
+ }
+
+ var newMapRequest = "";
+ for (var ii = 0; ii < currentMapObject.wms.length; ii++){
+ var currentWms = currentMapObject.wms[ii];
+ if (!(currentWms.gui_wms_visible > 0)) {
+ continue;
+ }
+ myMapIds.push("map_"+ii);
+
+ newMapRequest += getLayerHtmlCode(frameName, i, ii);
+
+ }
+ writeTag(mb_mapObj[i].frameName, mb_mapObj[i].elementName, newMapRequest);
+ }
+ eventAfterMapRequest.trigger({
+ "frameName": frameName,
+ "myMapIds": myMapIds.join(",")
+ });
+/*
+ for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
+ eval(mb_MapRequestSubFunctions[i]);
+ }
+*/
+}
+
+function getLayerHtmlCode (frameName, i, ii) {
+ var currentMapObject = mb_mapObj[i];
+ var currentWms = currentMapObject.wms[ii];
+
+ var myDivId = "div_" + ii;
+ var myMapId = "map_" + ii;
+ //disable Layer which are out of scale
+ var validLayers = mb_checkScale(frameName, i, ii);
+ var layerNames = validLayers.toString();
+
+ var newMapURL = false;
+ var opacityString = "";
+ if (currentMapObject.layers[ii] !== "" && layerNames !== ''){
+ // get map URL
+ newMapURL = currentMapObject.getMapUrl(i, ii);
+
+ var currentOpacity = currentWms.gui_wms_mapopacity;
+ if (currentOpacity != 1) {
+ opacityString += "opacity:" + currentOpacity + "; ";
+ opacityString += "Filter: Alpha(Opacity=" + currentOpacity*100 + "); ";
+ opacityString += "-moz-opacity:" + currentOpacity + " ; ";
+ opacityString += "-khtml-opacity:" + currentOpacity;
+ }
+ }
+
+ var imageString = "<img id='"+myMapId+"' name='mapimage' ";
+ imageString += "src='" + newMapURL + "' ";
+ imageString += "width='"+currentMapObject.width+"' ";
+ imageString += "height='"+currentMapObject.height+"' ";
+ imageString += "border='0'>";
+
+ var newMapRequest = "<div id='"+myDivId+"' ";
+ newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
+ newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
+ newMapRequest += imageString;
+ newMapRequest += "</div>";
+
+ currentMapObject.mapURL[ii]= newMapURL;
+ currentWms.mapURL = newMapURL;
+
+ if (mb_log && currentWms.mapURL) {
+ var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
+ }
+
+ return newMapRequest;
+}
+
+function setSingleMapRequest(frameName,wms_id){
+ var functionName = 'setSingleMapRequest';
+
+ eventBeforeMapRequest.trigger({frameName:frameName});
+
+ var ts = mb_timestamp();
+
+ for(i = 0; i < mb_mapObj.length; i++){
+ var currentMapObject = mb_mapObj[i];
+ if (currentMapObject.frameName != frameName) {
+ continue;
+ }
+
+ for (var ii=0; ii < currentMapObject.wms.length; ii++){
+ var currentWms = currentMapObject.wms[ii];
+ if (currentWms.wms_id != wms_id) {
+ continue;
+ }
+
+ var newMapRequest = getLayerHtmlCode(frameName, i, ii);
+
+ if (mb_log) {
+ var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+ }
+ var myDivId = "div_" + ii;
+ writeTag(currentMapObject.frameName, myDivId, newMapRequest);
+ var myMapId = "map_" + ii;
+ eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
+ return true;
+ }
+ }
+ return false;
+}
+
+
+function mb_restateLayers(frameName,wms_id){
+ //alert(frameName + " / " + wms_id);
+ var ind = getMapObjIndexByName(frameName);
+ for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_id == wms_id){
+ var cnt_layers = 0;
+ var cnt_querylayers = 0;
+ var layers = "";
+ var styles = "";
+ var querylayers = "";
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible == 1 && !mb_mapObj[ind].wms[i].objLayer[ii].has_childs){
+ if(cnt_layers > 0){layers += ","; styles += ","; }
+ layers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
+ //alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
+ styles += "";
+ cnt_layers++;
+ }
+ if(mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer == 1 && !mb_mapObj[ind].wms[i].objLayer[ii].has_childs){
+ if(cnt_querylayers > 0){querylayers += ",";}
+ querylayers += mb_mapObj[ind].wms[i].objLayer[ii].layer_name;
+ cnt_querylayers++;
+ }
+ }
+ mb_mapObj[ind].layers[i] = layers;
+ mb_mapObj[ind].querylayers[i] = querylayers;
+ mb_mapObj[ind].styles[i] = styles;
+ }
+ }
+}
+
+function mb_checkScale(frameName,mObj,wmsObj){
+ var thisLayer = mb_mapObj[mObj].layers[wmsObj].split(",");
+ var thisScale = mb_getScale(frameName);
+ var str_layer = "";
+ var cnt_layer = 0;
+ for(var i=0; i<mb_mapObj[mObj].wms[wmsObj].objLayer.length; i++){
+ var myLayername = mb_mapObj[mObj].wms[wmsObj].objLayer[i].layer_name;
+ var myMinscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_minscale;
+ var myMaxscale = mb_mapObj[mObj].wms[wmsObj].objLayer[i].gui_layer_maxscale;
+ for(var ii=0; ii<thisLayer.length; ii++){
+ var minscaleOK = false;
+ var maxscaleOK = false;
+ if(thisLayer[ii] == myLayername){
+ if(myMinscale === 0 || thisScale >= myMinscale){minscaleOK = true;}
+ if(myMaxscale === 0 || thisScale <= myMaxscale){maxscaleOK = true;}
+ if(maxscaleOK === true && minscaleOK === true && !mb_mapObj[mObj].wms[wmsObj].objLayer[i].has_childs){
+ if(cnt_layer > 0){str_layer += ","; }//str_styles += ","; str_titles += ",";str_parent += ","; str_legendurls += ",";}
+ str_layer += thisLayer[ii];
+ cnt_layer++;
+ }
+ }
+ }
+ }
+ var str_layerstyles = [];
+ str_layerstyles[0] = str_layer;
+ return str_layerstyles;
+}
+function setFeatureInfoRequest(fName,x,y, path) {
+ var functionName = 'setFeatureInfoRequest';
+ var ts = mb_timestamp();
+ eventBeforeFeatureInfo.trigger({"fName":fName});
+/*
+ for(var i=0; i<mb_FeatureInfoPreFunctions.length; i++){
+ eval(mb_FeatureInfoPreFunctions[i]);
+ }
+*/
+ var cnt_fi = 0;
+ for(i=0; i<mb_mapObj.length; i++){
+ if(mb_mapObj[i].frameName == fName){
+ for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
+ var newfeatureInfoRequest = "";
+ var requestParams = "";
+ var validation = false;
+ newfeatureInfoRequest += mb_mapObj[i].wms[ii].wms_getfeatureinfo;
+ newfeatureInfoRequest += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getfeatureinfo);
+
+ if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){requestParams += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=feature_info&";}
+ if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){requestParams += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetFeatureInfo&SERVICE=WMS&";}
+ requestParams += "SRS="+mb_mapObj[i].epsg+"&";
+ requestParams += "BBOX="+mb_mapObj[i].extent+"&";
+ requestParams += "WIDTH="+mb_mapObj[i].width+"&";
+ requestParams += "HEIGHT="+mb_mapObj[i].height+"&";
+ requestParams += "LAYERS="+mb_mapObj[i].layers[ii]+"&";
+ requestParams += "STYLES="+mb_mapObj[i].styles[ii]+"&";
+ requestParams += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
+ requestParams += "INFO_FORMAT="+mb_mapObj[i].wms[ii].gui_wms_featureinfoformat+"&";
+ requestParams += "EXCEPTIONS=application/vnd.ogc.se_xml&";
+ if(mb_feature_count > 0){
+ requestParams += "FEATURE_COUNT="+mb_feature_count+"&";
+ }
+ requestParams += "QUERY_LAYERS="+mb_mapObj[i].querylayers[ii]+"&";
+ requestParams += "X=" + x + "&";
+ requestParams += "Y=" + y;
+
+ if(mb_mapObj[i].querylayers[ii] !== "" && mb_mapObj[i].layers[ii] !== ""){
+ validation = true;
+ }
+ //add vendor-specific
+ for(var v=0; v < mb_vendorSpecific.length; v++){
+ var vendorSpecificString = eval(mb_vendorSpecific[v]);
+ requestParams += "&" + vendorSpecificString;
+ }
+ if(mb_log && validation){
+ var tmp = eval(mb_log + "('" + newfeatureInfoRequest + requestParams + "','" + ts + "')");
+ }
+ if(document.getElementById("FeatureInfoRedirect") && validation){
+ newfeatureInfoRequest += requestParams;
+ if(path){
+ window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr;
+ }
+ else{
+ window.frames.FeatureInfoRedirect.document.getElementById(mb_mapObj[i].wms[ii].wms_id).src = newfeatureInfoRequest;
+ }
+ cnt_fi++;
+ }
+ else if(path && validation){
+ newfeatureInfoRequest += requestParams;
+ try{
+ var p = new mb_popup("Feature Info","url:"+path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr,300,400);
+ p.show();
+ }catch(e){
+ window.open(path + "?url=" + escape(newfeatureInfoRequest)+"&"+mb_nr, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+ }
+ cnt_fi++;
+ }
+ else if(validation){
+ newfeatureInfoRequest += requestParams;
+ try{
+ var p = new mb_popup("Feature Info","url:"+newfeatureInfoRequest,300,400);
+ p.show();
+ }
+ catch(e){
+ window.open(newfeatureInfoRequest, "" , "width=300,height=400,scrollbars=yes,resizable=yes");
+ }
+ cnt_fi++;
+ }
+ }
+ }
+ }
+ if(cnt_fi === 0){
+ alert(unescape("Please select a layer! \n Bitte waehlen Sie eine Ebene zur Abfrage aus!"));
+ }
+}
+
+/*
+ * global function to zoom a mapobject
+ *
+ * use: mb_mapObj.zoom() {@link mb_mapObj_const#zoom}
+ * @deprecated
+ *
+ */
+function zoom(frameName,in_, factor,x,y) {
+ var obj = getMapObjByName(frameName);
+ if(x && y){
+ obj.zoom(in_, factor, x, y);
+ }
+ else{
+ obj.zoom(in_, factor, false, false);
+ }
+ setMapRequest(frameName);
+}
+function mb_panMap(frameName,dir){
+ var ind = getMapObjIndexByName(frameName);
+ var arrayBBox = mb_mapObj[ind].extent.split(",");
+ var minx = parseFloat(arrayBBox[0]);
+ var miny = parseFloat(arrayBBox[1]);
+ var maxx = parseFloat(arrayBBox[2]);
+ var maxy = parseFloat(arrayBBox[3]);
+ var xtentx = parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]);
+ var xtenty = parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+
+ if(dir == "NW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+ if(dir == "N"){miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+ if(dir == "NE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny + (xtenty/2); maxy = maxy + (xtenty/2);}
+ if(dir == "W"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2);}
+ if(dir == "E"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2);}
+ if(dir == "SW"){minx = minx - (xtentx/2); maxx = maxx - (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+ if(dir == "S"){miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+ if(dir == "SE"){minx = minx + (xtentx/2); maxx = maxx + (xtentx/2); miny = miny - (xtenty/2); maxy = maxy - (xtenty/2);}
+ mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+ setMapRequest(frameName);
+}
+
+function handleSelectedLayer (frameName, wms_title, layerName, type, status) {
+// alert(frameName + " , " +wms_title + " , " +layerName + " , " +type + " , " +status);
+// type = {visible || querylayer] status = {0 || 1}
+ for (var i=0; i < mb_mapObj.length; i++) {
+ if (mb_mapObj[i].frameName == frameName) {
+ var cnt_layer = 0;
+ var str_layer = "";
+ var myMapObj = i;
+ for (var ii = 0; ii < mb_mapObj[i].wms.length; ii++) {
+ if (mb_mapObj[i].wms[ii].wms_title == wms_title) { //ii is true
+ var myWMS = ii;
+ if (type == "visible") {
+ var arrayLayer = mb_mapObj[i].layers[ii].split(",");
+ }
+ if (type == "querylayer") {
+ var arrayLayer = mb_mapObj[i].querylayers[ii].split(",");
+ }
+ for (var iii = 1; iii < mb_mapObj[i].wms[ii].objLayer.length; iii++) {
+ var layer_name = mb_mapObj[i].wms[ii].objLayer[iii].layer_name;
+ if (type == "querylayer") {
+ if (layer_name == layerName && status == 1 && mb_mapObj[i].wms[ii].objLayer[iii].layer_queryable == 1){
+ if (cnt_layer > 0) {
+ str_layer += ",";
+ }
+ str_layer += layer_name;
+ cnt_layer++;
+ }
+ }
+ else if (type == "visible") {
+ if (layer_name == layerName && status == 1) {
+ if (cnt_layer > 0) {
+ str_layer += ",";
+ }
+ str_layer += layer_name;
+ cnt_layer++;
+ }
+ }
+ for (var iiii = 0; iiii < arrayLayer.length; iiii++) {
+ if (layer_name == arrayLayer[iiii] && layer_name != layerName) {
+ if (cnt_layer > 0) {
+ str_layer += ",";
+ }
+ str_layer += layer_name;
+ cnt_layer++;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ if (type == "visible") {
+ mb_mapObj[myMapObj].layers[myWMS] = str_layer;
+ var array_str_layer = str_layer.split(",");
+ var str_styles = "";
+ for (var cnt=0; cnt < array_str_layer.length; cnt++) {
+ if (cnt > 0) {
+ str_styles += ",";
+ }
+ str_styles += "";
+ }
+ mb_mapObj[myMapObj].styles[myWMS] = str_styles;
+ }
+ if (type == "querylayer") {
+ mb_mapObj[myMapObj].querylayers[myWMS] = str_layer;
+ }
+/*
+ if(type == 'visible'){
+ setSingleMapRequest(frameName,wms_title);
+ }
+*/
+}
+
+function handleSelectedLayer_array(mapObj, array_wms, array_layer, type, status){
+ //alert(mapObj+" / "+array_wms[0]+" / "+ array_layer[0]+" / "+ type+" / "+ status);
+ var ind = getMapObjIndexByName(mapObj);
+ for(var j=0; j<array_wms.length; j++){
+ for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_id == array_wms[j]){
+ var check = false;
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ if(mb_mapObj[ind].wms[i].wms_id == array_wms[j] && mb_mapObj[ind].wms[i].objLayer[ii].layer_name == array_layer[j]){
+ if(type == "visible"){
+ mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_visible = parseInt(status, 10);
+ //alert(mb_mapObj[ind].wms[i].objLayer[ii].layer_name);
+ check = true;
+ }
+ if(type == "querylayer" && (mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == "1" || mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_queryable == 1)){
+ mb_mapObj[ind].wms[i].objLayer[ii].gui_layer_querylayer = parseInt(status, 10);
+ }
+ }
+ }
+ mb_restateLayers(mapObj, array_wms[j]);
+ //alert('restate');
+ /*
+ * hier noch checken, welche wms sich geaendert haben und disctinct eine singleRequest aufrufen:
+ */
+ if(check === true){
+
+ if(mb_mapObj[ind].wms[i].gui_wms_visible == 1){
+ setSingleMapRequest(mapObj,mb_mapObj[ind].wms[i].wms_id);
+ //alert('sSMR');
+ }
+ }
+ }
+ }
+ }
+}
+
+function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
+ var ind = getMapObjIndexByName(frameName);
+ var width = parseInt(mb_mapObj[ind].width, 10);
+ var height = parseInt(mb_mapObj[ind].height, 10);
+ var arrayBBox = mb_mapObj[ind].extent.split(",");
+ var minX = parseFloat(arrayBBox[0]);
+ var minY = parseFloat(arrayBBox[1]);
+ var maxX = parseFloat(arrayBBox[2]);
+ var maxY = parseFloat(arrayBBox[3]);
+ var deltaX = (maxX - minX)/width;
+ var deltaY = (maxY - minY)/height;
+ if(deltaX > 0){
+ var roundx = 1/Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
+ }
+ else{
+ var roundx = Math.pow(10,(Math.round(Math.log(deltaX)/Math.log(10))));
+ }
+ if(deltaY > 0){
+ var roundy = 1/Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
+ }
+ else{
+ var roundy = Math.pow(10,(Math.round(Math.log(deltaY)/Math.log(10))));
+ }
+ var xtentx = maxX - minX;
+ var xtenty = maxY - minY;
+ var posX = parseFloat(minX + (myClickX / width) * xtentx);
+ var posY = parseFloat(maxY - (myClickY / height) * xtenty);
+ posX = Math.round(posX * roundx)/roundx;
+ posY = Math.round(posY * roundy)/roundy;
+ return [posX, posY];
+}
+
+function makeRealWorld2mapPos(frameName,rw_posx, rw_posy){
+ var ind = getMapObjIndexByName(frameName);
+ var mpObj = mb_mapObj[ind];
+ var arrayBBox = mpObj.extent.split(",");
+ var minX = parseFloat(arrayBBox[0]);
+ var minY = parseFloat(arrayBBox[1]);
+ var maxX = parseFloat(arrayBBox[2]);
+ var maxY = parseFloat(arrayBBox[3]);
+ return [Math.round((rw_posx - minX)*mpObj.width/(maxX - minX)), Math.round((maxY - rw_posy)*mpObj.height/(maxY - minY))];
+}
+
+function mb_arrangeElement(frameName, elName, left, top) {
+ if(frameName !== ""){
+ window.frames[frameName].document.getElementById(elName).style.top = top;
+ window.frames[frameName].document.getElementById(elName).style.left = left;
+ }
+ else{
+ document.getElementById(elName).style.top = top;
+ document.getElementById(elName).style.left = left;
+ }
+}
+
+/***********************Drag & Drop***********************/
+function mb_getMousePos(e,fName){
+if(fName){
+ if(ie){
+ clickX = window.frames[fName].event.clientX;
+ clickY = window.frames[fName].event.clientY;
+ }
+ else{
+ clickX = e.pageX;
+ clickY = e.pageY;
+ }
+ }
+ else{
+ if(ie){
+ clickX = event.clientX;
+ clickY = event.clientY;
+ }
+ else{
+ clickX = e.pageX;
+ clickY = e.pageY;
+ }
+ }
+ var pos = [clickX,clickY];
+ return pos;
+}
+// function for object-identification
+function getMapObjIndexByName(frameName){
+ for(var i=0; i<mb_mapObj.length; i++){
+ if(mb_mapObj[i].frameName == frameName){
+ return i;
+ }
+ }
+}
+function getMapObjByName(frameName){
+ for(var i=0; i<mb_mapObj.length; i++){
+ if(mb_mapObj[i].frameName == frameName){
+ return mb_mapObj[i];
+ }
+ }
+ return false;
+}
+function mb_getLayerTitleByName(map_index, wms_index, myLayer_name){
+ for(var i=0; i<mb_mapObj[map_index].wms[wms_index].objLayer.length; i++){
+ if(mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_name == myLayer_name){
+ return mb_mapObj[map_index].wms[wms_index].objLayer[i].layer_title;
+ }
+ }
+}
+function getWMSIDByTitle(frameName,wms_title){
+ var ind = getMapObjIndexByName(frameName);
+ for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_title == wms_title){
+ //return i;
+ return mb_mapObj[ind].wms[i].wms_id;
+ }
+ }
+}
+function getWMSIndexByTitle(frameName,wms_title){
+ var ind = getMapObjIndexByName(frameName);
+ for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_title == wms_title){
+ return i;
+ }
+ }
+}
+function getWMSIndexById(frameName,wms_id){
+ var ind = getMapObjIndexByName(frameName);
+ for(var i=0; i< mb_mapObj[ind].wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_id == wms_id){
+ return i;
+ }
+ }
+}
+//scale
+function mb_getScale(frameName) {
+
+ var myScale = eventBeforeGetScale.trigger({"frameName":frameName});
+/*
+ for(var i=0; i<mb_GetScalePreFunctions.length; i++){
+ var myScale = eval(mb_GetScalePreFunctions[i]);
+ }
+*/
+ if(typeof(myScale) == "number"){
+ var Y_str = myScale;
+ }
+ else{
+ var ind = getMapObjIndexByName(frameName);
+ var arrayBBox = mb_mapObj[ind].extent.split(",");
+ var xtenty = parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]);
+ var scaleY = (xtenty / mb_mapObj[ind].height) *(mb_resolution * 100);
+ if (scaleY<1){
+ var Y_str = scaleY;
+ }else{
+ var Y_str = Math.round(scaleY);
+ }
+ }
+ return Y_str;
+}
+
+function mb_repaintScale(frameName, x, y, scale){
+ var ind = getMapObjIndexByName(frameName);
+ if(x === null && y === null){
+ var arrayBBox = mb_mapObj[ind].extent.split(",");
+ x = parseFloat(arrayBBox[0]) + ((parseFloat(arrayBBox[2]) - parseFloat(arrayBBox[0]))/2);
+ y = parseFloat(arrayBBox[1]) + ((parseFloat(arrayBBox[3]) - parseFloat(arrayBBox[1]))/2);
+ }
+ var minx = parseFloat(x) - (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
+ var miny = parseFloat(y) - (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
+ var maxx = parseFloat(x) + (mb_mapObj[ind].width / (mb_resolution * 100 *2) * scale);
+ var maxy = parseFloat(y) + (mb_mapObj[ind].height / (mb_resolution * 100 *2) * scale);
+ mb_repaint(frameName,minx, miny, maxx, maxy);
+}
+function mb_repaint(frameName,minx,miny,maxx,maxy){
+ var ind = getMapObjIndexByName(frameName);
+ mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+ setMapRequest(frameName);
+}
+/*
+ * converts the extent of the mapobject so that the maximum extent will be displayed {@link mb_mapObj_const#calculateExtent}
+ * use: mb_mapObj.calculateExtent
+ * @deprecated
+ *
+ */
+function mb_calculateExtent(frameName,minx,miny,maxx,maxy){
+ var map = getMapObjByName(frameName);
+ var extent = new Extent(minx,miny,maxx,maxy);
+ map.calculateExtent(extent);
+}
+/*
+ * @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){
+ this.minx = parseFloat(minx);
+ this.miny = parseFloat(miny);
+ this.maxx = parseFloat(maxx);
+ this.maxy = parseFloat(maxy);
+ this.extentx = this.maxx - this.minx;
+ this.extenty = this.maxy - this.miny;
+ this.centerx = this.minx + this.extentx/2;
+ this.centery = this.miny + this.extenty/2;
+ return this;
+}
+
+function mb_showHighlight(frameName,x,y){
+ var pos = makeRealWorld2mapPos(frameName,x, y);
+ mb_arrangeElement(frameName,"highlight",pos[0]-7, pos[1]-7);
+ window.frames[frameName].document.getElementById("highlight").style.visibility = 'visible';
+}
+function mb_hideHighlight(frameName){
+ mb_arrangeElement(frameName,"highlight",-20, -20);
+ mb_arrangeElement(frameName,"highlight",-20, -20);
+ window.frames[frameName].document.getElementById("highlight").style.visibility = 'hidden';
+}
+function mb_permanentHighlight(frameName,x,y){
+ var pos = makeRealWorld2mapPos(frameName,x, y);
+ mb_arrangeElement(frameName,"permanent",pos[0]-7, pos[1]-7);
+ window.frames[frameName].document.getElementById("permanent").style.visibility = 'visible';
+}
+// framename, commaseparated coordinates, commaseparated rgb values (color)
+//new: coords is array!
+function mb_markResult(frameName,geom,col){
+ var x = "";
+ var y = "";
+ var tmp = [];
+ var ind = getMapObjIndexByName(frameName);
+ for(var i=0; i < geom.length; i++){
+ if(i > 0){
+ x += ":";
+ y += ":";
+ }
+ tmp = geom[i].split(",");
+ for(var ii=0; ii < tmp.length; ii+=2){
+ var pos = makeRealWorld2mapPos(frameName,tmp[ii], tmp[ii+1]);
+ if(ii>0){
+ x += ",";
+ y += ",";
+ }
+ x += pos[0];
+ y += pos[1];
+ }
+ }
+ var source = "<img src='../extensions/markResult.php?x=" + x + "&y=" + y + "&width=" + mb_mapObj[ind].width + "&height=" + mb_mapObj[ind].height + "&color="+col+"'>";
+ //prompt("",source);
+ writeTag(frameName,"markResult",source);
+}
+function mb_disableResult(frameName){
+ writeTag(frameName,"markResult","");
+}
+
+function mb_registerGML(frameName,obj){
+ var ind = getMapObjIndexByName(frameName);
+ mb_mapObj[ind].geom = obj;
+}
+function mb_timestamp(){
+ var d = new Date();
+ var ts = Math.round(Date.parse(d)/1000);
+ return ts;
+}
+function mb_getlayerposbyname(objInd,wmsInd,lname){
+ var t = mb_mapObj[objInd].wms[wmsInd];
+ for(var i=0; i < t.objLayer.length; i++){
+ if(t.objLayer[i].layer_name == lname){
+ return t.objLayer[i].layer_pos;
+ }
+ }
+}
+function mb_getLayerObjByName(fname,wms_id,layer_name){
+ var ind = getMapObjIndexByName(fname);
+ var wmsInd = getWMSIndexById(fname,wms_id);
+ var t = mb_mapObj[ind].wms[wmsInd];
+ for(var i=0; i < t.objLayer.length; i++){
+ if(t.objLayer[i].layer_name == layer_name){
+ return t.objLayer[i];
+ }
+ }
+}
+function mb_getchildsbyname(objInd,wmsInd,lname){
+ var t = mb_mapObj[objInd].wms[wmsInd];
+ var pos = mb_getlayerposbyname(objInd, wmsInd,lname);
+ var l = [];
+ l.name = [];
+ l.title = [];
+ l.legendurl = [];
+ for(var i=0; i < t.objLayer.length; i++){
+ if(t.objLayer[i].layer_parent == pos){
+ l.name[l.name.length] = t.objLayer[i].layer_name;
+ l.title[l.title.length] = t.objLayer[i].layer_title;
+ if(t.objLayer[i].layer_style.length>0){
+ l.legendurl[l.legendurl.length] = t.objLayer[i].layer_style[0].legendurl;
+ }else{
+ l.legendurl[l.legendurl.length] = 0 ;
+ }
+ }
+ }
+ if(l.name.length > 0){
+ return l;
+ }
+ else{
+ return false;
+ }
+}
+/*
+ ***************************************************************************************
+ * button handling
+ ***************************************************************************************
+ */
+
+var mb_button = [];
+
+function mb_regButton_frame(wii, frameName, param){
+ var ind = mb_button.length;
+ mb_button[ind] = new mb_conButton(wii, ind);
+ if (frameName === null) {
+ if (param === null) {
+ eval(wii+"("+ind+")");
+ }
+ else {
+ eval(wii+"("+ind+", "+param+")");
+ }
+ }
+ else if (param === null) {
+ eval("window.frames['" + frameName + "']."+wii+"("+ind+")");
+ }
+ else {
+ eval("window.frames['" + frameName + "']."+wii+"("+ind+", "+param+")");
+ }
+ mb_button[ind].prev = mb_button[ind].src;
+ mb_button[ind].src = mb_button[ind].img_off;
+ mb_button[ind].onmouseover = function () {
+ mb_button_over(ind);
+ };
+ mb_button[ind].onmouseout = function(){
+ mb_button_out(ind);
+ };
+ mb_button[ind].onclick = function(){
+ mb_button_click(ind);
+ };
+ if (frameName === null) {
+ mb_button[ind].frameName = "";
+ }
+ else {
+ mb_button[ind].frameName = frameName;
+ }
+}
+
+function mb_regButton(wii){
+ mb_regButton_frame(wii, null, null);
+}
+
+function mb_conButton(wii, ind){
+ this.wii = wii;
+ return true;
+}
+function mb_button_over(ind){
+ if(mb_button[ind].status === 0){
+ mb_button[ind].prev = mb_button[ind].src;
+ mb_button[ind].src = mb_button[ind].img_over;
+ }
+}
+function mb_button_out(ind){
+ mb_button[ind].src = mb_button[ind].prev;
+}
+function mb_button_click(ind){
+ var mbStatus = mb_button[ind].status;
+ if(mbStatus === 0){
+ mb_disableButton(mb_button[ind].elName);
+ mb_button[ind].prev = mb_button[ind].img_on;
+ mb_button[ind].src = mb_button[ind].img_on;
+ mb_button[ind].status = 1;
+ if (mb_button[ind].frameName !== "") {
+ window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).go();
+ }
+ else {
+ document.getElementById(mb_button[ind].elName).go();
+ }
+ }
+ else{
+ mb_button[ind].prev = mb_button[ind].img_off;
+ mb_button[ind].src = mb_button[ind].img_off;
+ mb_button[ind].status = 0;
+ if (mb_button[ind].frameName !== "") {
+ window.frames[mb_button[ind].frameName].document.getElementById(mb_button[ind].elName).stop();
+ }
+ else {
+ document.getElementById(mb_button[ind].elName).stop();
+ }
+ }
+}
+function mb_disableButton(elName){
+ for(var i=0; i<mb_button.length; i++){
+ if(mb_button[i].elName != elName && mb_button[i].status == 1){
+ mb_button[i].status = 0;
+ if (mb_button[i].frameName !== "") {
+ window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+ window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+ }
+ else {
+ document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+ document.getElementById(mb_button[i].elName).stop();
+ }
+ return true;
+
+ }
+ }
+}
+function mb_disableThisButton(elName){
+ for(var i=0; i<mb_button.length; i++){
+ if(mb_button[i].elName == elName && mb_button[i].status == 1){
+ //alert(mb_button[i].elName);
+ mb_button[i].status = 0;
+ if (mb_button[i].frameName !== "") {
+ window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+ window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).stop();
+ }
+ else {
+ document.getElementById(mb_button[i].elName).src = mb_button[i].img_off;
+ document.getElementById(mb_button[i].elName).stop();
+ }
+ return true;
+
+ }
+ }
+}
+function updateButtonTooltips(obj) {
+/*
+ * the buttons are only initialized on mouseover!
+ * So when localizing, not all buttons may have been registered
+ *
+ for(var i=0; i<mb_button.length; i++){
+// console.log("button %i", i);
+ for(var j=0; j<obj.length; j++){
+ if (mb_button[i].elName == obj[j].id) {
+// console.log("%s %s", mb_button[i].elName, obj[j].id);
+ if (mb_button[i].frameName !== "") {
+ window.frames[mb_button[i].frameName].document.getElementById(mb_button[i].elName).title = obj[j].title;
+ }
+ else {
+ document.getElementById(mb_button[i].elName).title = obj[j].title;
+ }
+ }
+ }
+ }
+*/
+
+ // an alternative, fixes above error,
+ // but this one only changes those in the main frame
+ var imageArray = document.getElementsByTagName("img");
+ for (var i = 0; i < imageArray.length; i++) {
+ for(var j=0; j<obj.length; j++){
+ if (imageArray[i].id == obj[j].id) {
+ document.getElementById(imageArray[i].id).title = obj[j].title;
+ }
+ }
+ }
+}
+
+function mb_localizeButtons(){
+ mb_ajax_json("../php/mod_button_tooltips.php", function(obj, status){
+ updateButtonTooltips(obj);
+ });
+}
+
+eventLocalize.register(function () {
+ mb_localizeButtons();
+});
+
+eventInit.register(function () {
+ mb_localizeButtons();
+});
+
+
+/*
+ ***************************************************************************************
+ * miscellaneous functions
+ ***************************************************************************************
+ */
+
+function cloneObject(obj) {
+ if (typeof obj !== 'object' || obj === null) {
+ return obj;
+ }
+ var c = obj instanceof Array ? [] : {};
+ for (var i in obj) {
+ var prop = obj[i];
+ if (typeof prop == 'object') {
+ if (prop instanceof Array) {
+ c[i] = [];
+ for (var j = 0; j < prop.length; j++) {
+ if (typeof prop[j] != 'object') {
+ c[i].push(prop[j]);
+ } else {
+ c[i].push(cloneObject(prop[j]));
+ }
+ }
+ } else {
+ c[i] = cloneObject(prop);
+ }
+ } else {
+ c[i] = prop;
+ }
+ }
+ return c;
+}
+
+
+/*
+ ***************************************************************************************
+ * deprecated functions
+ ***************************************************************************************
+ */
+
+// only used in mod_perimeter.php
+// previously used in mod_initWmc.php, mod_digitize_tab.php, mod_geometryArray.js
+function mb_checkTag(frameName, tagName, elementId, appendAtTagName, attributes){
+ var oldElement;
+ var newElement;
+ var prefix;
+ if(frameName && frameName !== ""){
+ prefix = window.frames[frameName].document;
+ }
+ else if(!frameName || frameName === ""){
+ prefix = document;
+ }
+ oldElement = prefix.getElementById(elementId);
+ if (oldElement === null) {
+ newElement = prefix.createElement(tagName);
+ newElement = prefix.getElementsByTagName(appendAtTagName)[0].appendChild(newElement);
+ }
+ else {
+ if (oldElement.nodeName.toLowerCase() == tagName.toLowerCase()) {
+ for (var i=0; i<attributes.length; i++) {
+ oldElement.setAttribute(attributes[i][0], attributes[i][1]);
+ }
+ return oldElement;
+ }
+ else {
+ return false;
+ }
+ }
+ var newElementAttributeNode = document.createAttribute("id");
+ newElementAttributeNode.value = elementId;
+ newElement.setAttributeNode(newElementAttributeNode);
+ for (var i=0; i<attributes.length; i++) {
+ newElement.setAttribute(attributes[i][0], attributes[i][1]);
+ }
+ return newElement;
+}
\ No newline at end of file
Copied: branches/beck_dev/mapbender/lib/point.js (from rev 2450, branches/beck_dev/mapbender/http/javascripts/point.js)
===================================================================
--- branches/beck_dev/mapbender/lib/point.js (rev 0)
+++ branches/beck_dev/mapbender/lib/point.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -0,0 +1,192 @@
+/*
+* $Id$
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details.
+*/
+//http://www.mapbender.org/index.php/point.js
+
+/**
+ * @class A class representing a two-dimensional point.
+ *
+ * @constructor
+ * @param {Float} x x value of the {@link Point}
+ * @param {Float} y y value of the {@link Point}
+ */
+ function Point(x, y, z){
+ /**
+ * x value of the {@link Point}
+ *
+ * @type Float
+ */
+// this.x = parseFloat(x);
+ this.x = x;
+ /**
+ * y value of the {@link Point}
+ *
+ * @type Float
+ */
+// this.y = parseFloat(y);
+ this.y = y;
+
+ this.z = z;
+
+}
+/**
+ * computes the distance between a {@link Point} p and this {@link Point}
+ *
+ * @param {Point} p the distance between this {@link Point} and the {@link Point} p is computed.
+ * @return {Float} the distance between the two {@link Point} objects.
+ */
+Point.prototype.dist = function(p){
+ return Math.sqrt(Math.pow(this.y-p.y,2) + Math.pow(this.x-p.x,2)) ;
+};
+/**
+ * checks if the coordinates of this {@link Point} match the coordinates of a {@link Point} p
+ *
+ * @param {Point} p
+ * @return {Boolean} true if the two points are equal; elso false
+ */
+Point.prototype.equals = function(p){
+ if (this.x == p.x && this.y == p.y) {return true;}
+ return false;
+};
+/**
+ * subtracts a {@link Point} p from this {@link Point}
+ *
+ * @param {Point} p
+ * @return a new {@link Point} with the difference of the two points
+ */
+Point.prototype.minus = function(p){
+ return new Point(this.x-p.x, this.y-p.y);
+};
+/**
+ * adds this {@link Point} to a {@link Point} p
+ *
+ * @param {Point} p
+ * @return a new {@link Point} with the sum of the two points
+ */
+Point.prototype.plus = function(p){
+ return new Point(this.x+p.x, this.y+p.y);
+};
+/**
+ * divides this {@link Point} by a scalar c
+ *
+ * @param {Float} c divisor
+ * @return a new {@link Point} divided by c
+ */
+Point.prototype.dividedBy = function(c){
+ if (c !== 0) {
+ return new Point(this.x/c, this.y/c);
+ }
+ var e = new Mb_exception("Point.dividedBy: Division by zero");
+ return false;
+};
+/**
+ * multiplies this {@link Point} by a scalar c
+ *
+ * @param {Float} c factor
+ * @return a new {@link Point} multiplied by c
+ */
+Point.prototype.times = function(c){
+ return new Point(this.x*c, this.y*c);
+};
+/**
+ * rounds the coordinates to numOfDigits digits
+ *
+ * @param numOfDigits the coordinate will be rounded to numOfDigits digits
+ * @return a new {@link Point} rounded to numOfDigits digits
+ * @type Point
+ */
+Point.prototype.round = function(numOfDigits){
+ return new Point(roundToDigits(this.x, numOfDigits), roundToDigits(this.y, numOfDigits));
+};
+/**
+ * @returns a {String} representation of this Point
+ * @type String
+ */
+Point.prototype.toString = function(){
+ if (typeof(this.z == "undefined")) {
+ return "[" + this.x + ", " + this.y + "]";
+ }
+ else {
+ return "[" + this.x + ", " + this.y + ", " + this.z + "]";
+ }
+};
+
+
+//------------------------------------------------------------------------
+// possible improvement: point has flag: map OR real. additional functions: toReal, toMap
+/**
+ * @ignore
+ */
+function mapToReal(frameName, aPoint){
+ var v;
+ if (typeof(mb_mapObj) == 'object') {
+ v = makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
+ }
+ else {
+ if (typeof(parent.mb_mapObj) == 'object') {
+ v = parent.makeClickPos2RealWorldPos(frameName, aPoint.x, aPoint.y);
+ }
+ else {
+ alert('where am i?');
+ }
+ }
+ return new Point(v[0], v[1]);
+}
+/**
+ * @ignore
+ */
+function realToMap(frameName, aPoint) {
+ var v;
+ if (typeof(mb_mapObj) == 'object') {
+ v = makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+ }
+ else if (typeof(parent.mb_mapObj) == 'object') {
+ v = parent.makeRealWorld2mapPos(frameName, aPoint.x, aPoint.y);
+ }
+ else {
+ var e = new Mb_exception('Point.realToMap:where am i?');
+ }
+ return new Point(v[0], v[1]);
+}
+/**
+ * @ignore
+ */
+function mb_calcExtent(frameName, min, max) {
+ var ind;
+ if (typeof(mb_mapObj) == 'object') {
+ ind = getMapObjIndexByName(frameName);
+ }
+ else if (typeof(parent.mb_mapObj) == 'object') {
+ ind = parent.getMapObjIndexByName(frameName);
+ }
+ else {
+ var e = new Mb_exception('Point.mb_calcExtent: function getMapObjIndexByName not found');
+ }
+ var extent = max.minus(min);
+ var center = extent.dividedBy(2).plus(min);
+
+ var relation_px_x = mb_mapObj[ind].width / mb_mapObj[ind].height;
+ var relation_px_y = mb_mapObj[ind].height / mb_mapObj[ind].width;
+ var relation_bbox_x = extent.x / extent.y;
+
+ var new_min;
+ var new_max;
+
+ if(relation_bbox_x <= relation_px_x){
+ new_min = new Point(center.x - relation_px_x * extent.y / 2, min.y);
+ new_max = new Point(center.x + relation_px_x * extent.y / 2, max.y);
+ }
+ else if(relation_bbox_x > relation_px_x){
+ 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_min.x +","+ new_min.y +","+ new_max.x +","+ new_max.y;
+}
+/**
+ * @ignore
+ */
+function roundToDigits(aFloat, numberOfDigits) {
+ return Math.round(aFloat*Math.pow(10, parseInt(numberOfDigits, 10)))/Math.pow(10, parseInt(numberOfDigits, 10));
+}
Copied: branches/beck_dev/mapbender/lib/style.js (from rev 2450, branches/beck_dev/mapbender/http/javascripts/style.js)
===================================================================
--- branches/beck_dev/mapbender/lib/style.js (rev 0)
+++ branches/beck_dev/mapbender/lib/style.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -0,0 +1,54 @@
+/**
+ * creates a style tag in the head of the document.
+ *
+ */
+var StyleTag = function() {
+
+ /**
+ * Creates the style tag in the head of the document. Something like a constructor.
+ *
+ */
+ var createStyleTag = function() {
+ // TODO: Internet Explorer routine seems a little buggy
+ if (top.ie) {
+ // create a Style Sheet object (IE only)
+ //styleSheetObj=document.createStyleSheet();
+ // get the DOM node of the style sheet object, set the type
+ //styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+ //styleObj.setAttribute("type","text/css");
+
+ // alternative way for IE: take existing styleSheet with index 0 instead of creating a new one
+ styleSheetObj=document.styleSheets[0];
+ }
+ else {
+ // create the style node, set the style
+ styleObj=document.createElement("style");
+ styleObj.setAttribute("type","text/css");
+ // append the node to the head
+ document.getElementsByTagName("head")[0].appendChild(styleObj);
+ }
+ };
+
+ /**
+ * Adds a class className with the CSS in cssString
+ */
+ this.addClass = function(className,cssString) {
+ // TODO: Internet Explorer routine seems a little buggy
+ if (top.ie) {
+ //add new style declaration to chosen styleSheet
+ var cssRules = cssString.split(";");
+ for (i=0; i<cssRules.length-1; i++){
+ styleSheetObj.addRule("."+className,cssRules[i]);
+ }
+ }
+ else {
+ // insert the content via createTextNode
+ styleObj.appendChild(document.createTextNode("."+className+"{\n\t"+cssString+"\n}\n"));
+ }
+ };
+
+ var styleObj;
+ var styleSheetObj; //IE only...
+
+ createStyleTag();
+};
\ No newline at end of file
Copied: branches/beck_dev/mapbender/lib/wfs_obj.js (from rev 2450, branches/beck_dev/mapbender/http/javascripts/wfs_obj.js)
===================================================================
--- branches/beck_dev/mapbender/lib/wfs_obj.js (rev 0)
+++ branches/beck_dev/mapbender/lib/wfs_obj.js 2008-05-28 15:03:41 UTC (rev 2476)
@@ -0,0 +1,75 @@
+//$Id$
+//$Header: /cvsroot/mapbender/mapbender/http/javascripts/wfs_obj.js,v 1.3 2005/09/13 14:38:11 bjoern_heuser Exp $
+//global variables
+var wfs = [];
+var wfs_featuretype_count = 0;
+var wfs_element_count = 0;
+//list of all wms-objects
+function add_wfs(
+ wfs_id,
+ wfs_version,
+ wfs_title,
+ wfs_abstract,
+ wfs_getcapabilities,
+ wfs_describefeaturetype){
+ wfs[wfs.length] = new wfs_const(
+ wfs_id,
+ wfs_version,
+ wfs_title,
+ wfs_abstract,
+ wfs_getcapabilities,
+ wfs_describefeaturetype);
+ //wfs_featuretype[wfs.length - 1] = [];
+}
+//the wms constructor
+function wfs_const(
+ wfs_id,
+ wfs_version,
+ wfs_title,
+ wfs_abstract,
+ wfs_getcapabilities,
+ wfs_describefeaturetype){
+
+ this.wfs_id = wfs_id;
+ this.wfs_version = wfs_version;
+ this.wfs_title = wfs_title;
+ this.wfs_abstract = wfs_abstract;
+ this.wfs_getcapabilities = wfs_getcapabilities;
+ this.wfs_describefeaturetype = wfs_describefeaturetype;
+
+ this.wfs_featuretype = [];
+ //alert(wfs_id + " , " +wfs_title + " , " +wfs_abstract + " , " +wfs_getcapabilities + " , " +wfs_describefeaturetype);
+}
+//featuretype
+function wfs_add_featuretype(
+ featuretype_name,
+ featuretype_title,
+ featuretype_srs,
+ featuretype_geomtype){
+
+ wfs[wfs.length-1].wfs_featuretype[wfs[wfs.length-1].wfs_featuretype.length] = new featuretype(
+ featuretype_name,
+ featuretype_title,
+ featuretype_srs,
+ featuretype_geomtype);
+//alert(featuretype_name + " , " +featuretype_title + " , " +featuretype_srs + " , " +featuretype_geomtype);
+}
+function featuretype(
+ featuretype_name,
+ featuretype_title,
+ featuretype_srs,
+ featuretype_geomtype){
+ this.featuretype_name = featuretype_name;
+ this.featuretype_title = featuretype_title;
+ this.featuretype_srs = featuretype_srs;
+ this.featuretype_geomtype = featuretype_geomtype;
+ this.element = [];
+ wfs_featuretype_count++;
+}
+//elements
+function wfs_add_featuretype_element(element_name, element_type, element_count, featuretype_count){
+ wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count] = [];
+ wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count].name = element_name;
+ wfs[wfs.length-1].wfs_featuretype[featuretype_count].element[element_count].type = element_type;
+ //alert(element_name +" , "+element_type);
+}
More information about the Mapbender_commits
mailing list