[Mapbender-commits] r2562 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jun 30 09:05:28 EDT 2008
Author: christoph
Date: 2008-06-30 09:05:28 -0400 (Mon, 30 Jun 2008)
New Revision: 2562
Modified:
trunk/mapbender/http/javascripts/map.js
Log:
moved code from core.js
Modified: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js 2008-06-30 12:14:51 UTC (rev 2561)
+++ trunk/mapbender/http/javascripts/map.js 2008-06-30 13:05:28 UTC (rev 2562)
@@ -1,690 +1,737 @@
-/**
- * used in mod_box1, mod_dragMapSize, mod_pan
- */
-var mb_start_x = 0;
-var mb_start_y = 0;
-var mb_end_x = 0;
-var mb_end_y = 0;
-
-/**
- * @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;
-}
-
-
-eventAfterInit.register(function () {
- // 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));
-}
-
-
-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){
+/**
+ * used in mod_box1, mod_dragMapSize, mod_pan
+ */
+var mb_start_x = 0;
+var mb_start_y = 0;
+var mb_end_x = 0;
+var mb_end_y = 0;
+
+/**
+ * @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;
+}
+
+
+eventAfterInit.register(function () {
+ // performs a map request for each map frame
+ for (var i = 0; i < mb_mapObj.length; i++){
+ setMapRequest(mb_mapObj[i].frameName);
+ }
+});
+
+eventBeforeFeatureInfo.register(function() {
+ for (var j=0; j<mb_mapObj.length; j++) {
+ var mapObj = mb_mapObj[j];
+
+ //
+ // set list of visible layers, active querylayers
+ // and styles for each WMS in this map
+ //
+
+ var cnt_layers;
+ var cnt_querylayers;
+ var styles;
+ var layers;
+ var querylayers = "";
+ for(i=0; i< mapObj.wms.length; i++){
+ cnt_layers = 0;
+ cnt_querylayers = 0;
+ styles = "";
+ layers = "";
+ querylayers = "";
+
+ for(var ii=0; ii<mapObj.wms[i].objLayer.length; ii++){
+ // layer is visible and not root layer
+ if(mapObj.wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
+ if(cnt_layers > 0){
+ layers += ","; styles += ",";
+ }
+ layers += wms[i].objLayer[ii].layer_name;
+ styles += "";
+ cnt_layers++;
+ }
+ // layer is queryable and not root layer
+ if(mapObj.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+ if(cnt_querylayers > 0){
+ querylayers += ",";
+ }
+ querylayers += wms[i].objLayer[ii].layer_name;
+ cnt_querylayers++;
+ }
+ }
+ mapObj.layers[i] = layers;
+ mapObj.styles[i] = styles;
+ mapObj.querylayers[i] = querylayers;
+ }
+ }
+});
+
+function mb_registerMapObj(frameName, elementName,wms_index,width, height){
+ mb_mapObj.push(new mb_mapObj_const(frameName, elementName, width, height, wms_index));
+}
+
+
+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 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 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 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;
-}
-
+ 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 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 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 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;
+}
+
More information about the Mapbender_commits
mailing list