[Mapbender-commits] r2544 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jun 23 12:13:23 EDT 2008
Author: christoph
Date: 2008-06-23 12:13:23 -0400 (Mon, 23 Jun 2008)
New Revision: 2544
Added:
trunk/mapbender/http/javascripts/map.js
trunk/mapbender/http/javascripts/map_obj.js
trunk/mapbender/http/javascripts/wms.js
Modified:
trunk/mapbender/http/javascripts/map.php
Log:
Added: trunk/mapbender/http/javascripts/map.js
===================================================================
--- trunk/mapbender/http/javascripts/map.js (rev 0)
+++ trunk/mapbender/http/javascripts/map.js 2008-06-23 16:13:23 UTC (rev 2544)
@@ -0,0 +1,690 @@
+/**
+ * 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){
+ 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;
+}
+
Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php 2008-06-23 16:01:16 UTC (rev 2543)
+++ trunk/mapbender/http/javascripts/map.php 2008-06-23 16:13:23 UTC (rev 2544)
@@ -18,7 +18,6 @@
# 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");
// see http://trac.osgeo.org/mapbender/ticket/79
ini_set('session.bug_compat_42',0);
@@ -63,6 +62,7 @@
echo "mapbender.versionNumber = '" . MB_VERSION_NUMBER . "';";
echo "mapbender.versionAppendix = '" . MB_VERSION_APPENDIX . "';";
echo "mapbender.releaseDate = new Date(".date("Y",MB_RELEASE_DATE).",".date("n",MB_RELEASE_DATE).",".date("j",MB_RELEASE_DATE).");";
+echo "mapbender.zoomMousewheel = " . ZOOM_MOUSEWHEEL . ";";
echo "var owsproxy = '".OWSPROXY."';";
echo "var global_mb_log_js = '".LOG_JS."';";
echo "var global_mb_log_level = '".LOG_LEVEL."';";
@@ -74,33 +74,29 @@
//
// Load external JavaScript libraries
//
-require_once(dirname(__FILE__) . "/../extensions/jquery.js");
+require_once(dirname(__FILE__) . "/../extensions/jquery-1.2.6.min.js");
require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
-
+require_once(dirname(__FILE__) . "/../extensions/jquery.mousewheel.min.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/basic.js");
require_once(dirname(__FILE__) . "/../../lib/div.js");
require_once(dirname(__FILE__) . "/../../lib/list.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__) . "/../../lib/wfs_obj.js");
require_once(dirname(__FILE__) . "/../../lib/style.js");
+require_once(dirname(__FILE__) . "/../../lib/button.js");
//
-// Load WMS
-//
-$wmsArray = wms::selectMyWmsByApplication($gui_id);
+// map obj
+//
+#require_once(dirname(__FILE__) . "/../../lib/map_obj.js");
+#require_once(dirname(__FILE__) . "/../../lib/map.js");
+#require_once(dirname(__FILE__) . "/../../lib/wms.js");
+#require_once(dirname(__FILE__) . "/../../lib/wfs_obj.js");
-for ($i = 0; $i < count($wmsArray); $i++) {
- $currentWms = $wmsArray[$i];
- $currentWms->createJsObjFromWMS();
-}
-
//
// Load JavaScript modules of GUI elements
//
@@ -134,17 +130,20 @@
$mb_res = db_prep_query($mb_sql, $mb_v, $mb_t);
while($row_js = db_fetch_array($mb_res)){
if($row_js["e_js_file"] != ""){
- $e_id = $row_js["e_id"];
- $e_src = $row_js["e_src"];
- $e_require = $row_js["e_requires"];
- $e_target = explode(",",$row_js["e_target"]);
- $currentFile = $row_js["e_js_file"];
- if (file_exists($currentFile)) {
- require_once($currentFile);
+ $jsArray = explode(",", $row_js["e_js_file"]);
+ for ($i = 0; $i < count($jsArray); $i++) {
+ $e_id = $row_js["e_id"];
+ $e_src = $row_js["e_src"];
+ $e_require = $row_js["e_requires"];
+ $e_target = explode(",",$row_js["e_target"]);
+ $currentFile = trim($jsArray[$i]);
+ if (file_exists($currentFile)) {
+ require_once($currentFile);
+ }
+ else {
+ $e = new mb_exception("Javascript not found: " . $currentFile);
+ }
}
- else {
- $e = new mb_exception("Javascript not found: " . $currentFile);
- }
}
}
?>
\ No newline at end of file
Added: trunk/mapbender/http/javascripts/map_obj.js
===================================================================
--- trunk/mapbender/http/javascripts/map_obj.js (rev 0)
+++ trunk/mapbender/http/javascripts/map_obj.js 2008-06-23 16:13:23 UTC (rev 2544)
@@ -0,0 +1,404 @@
+/*
+* $Id: map_obj.js 2517 2008-06-19 16:40:00Z christoph $
+* 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.
+*/
+var mb_mapObj = [];
+
+function mb_mapObj_const(frameName, elementName, width, height, wms_index){
+ this.width = width;
+ this.height = height;
+ this.frameName = frameName;
+ this.elementName = elementName;
+ this.layers = [];
+ this.styles = [];
+ this.querylayers = [];
+ this.geom = "";
+ this.gml = "";
+ this.wms = [];
+
+ //
+ // Add pointers to WMS objects which are in this map.
+ // If wms_index is set (=map is overview), only this
+ // WMS is being pointed to.
+ //
+ var index = 0;
+ for(var i=0; i < wms.length; i++){
+ var isValidWms = (wms_index === null) || (wms_index == i);
+ if (isValidWms) {
+ this.wms[index] = wms[i];
+ this.wms[index].mapURL = false;
+ index++;
+ }
+ }
+
+ //
+ // 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< this.wms.length; i++){
+ cnt_layers = 0;
+ cnt_querylayers = 0;
+ styles = "";
+ layers = "";
+ querylayers = "";
+
+ for(var ii=0; ii<this.wms[i].objLayer.length; ii++){
+ // layer is visible and not root layer
+ if(this.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(this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+ if(cnt_querylayers > 0){
+ querylayers += ",";
+ }
+ querylayers += wms[i].objLayer[ii].layer_name;
+ cnt_querylayers++;
+ }
+ }
+ this.layers[i] = layers;
+ this.styles[i] = styles;
+ this.querylayers[i] = querylayers;
+ }
+
+ this.epsg = wms[0].gui_wms_epsg;
+ this.extent = setExtent(this.width,this.height,this.epsg);
+ this.mapURL = [];
+ var styleTag = window.frames[this.frameName].document.getElementById(this.elementName).style;
+ styleTag.width = this.width;
+ styleTag.height = this.height;
+
+ /**
+ * get the width of the mapObj
+ *
+ * @member mb_mapObj_const
+ * @return width of the mapObj
+ * @type integer
+ */
+ this.getWidth = function(){
+ return parseInt(this.width, 10);
+ };
+
+ /**
+ * set the width of the mapObj
+ *
+ * @param {integer} widht the width of the mapObj
+ */
+ this.setWidth = function(width){
+ this.width = parseInt(width, 10);
+ };
+
+ /**
+ * get the height of the mapObj
+ *
+ * @member mb_mapObj_const
+ * @return width of the mapObj
+ * @type integer
+ */
+ this.getHeight = function(){
+ return parseInt(this.height, 10);
+ };
+
+ /**
+ * set the height of the mapObj
+ *
+ * @param {integer} height the height of the mapObj
+ */
+ this.setHeight = function(height){
+ this.height = parseInt(height, 10);
+ };
+
+ /**
+ * get the extent of the mapObj
+ *
+ * @member mb_mapObj_const
+ * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy
+ * @type string
+ */
+ this.getExtent = function(){
+ return this.extent;
+ };
+
+ /**
+ * get the extent as minx, maxx, miny, maxy
+ *
+ * @return extent and additional informations of the mapObj
+ * @type Object
+ */
+ this.getExtentInfos = function(){
+ var c = this.getExtent().split(",");
+ var ext = new Extent(c[0],c[1],c[2],c[3]);
+ return ext;
+ };
+
+ /**
+ * converts the extent of the mapobject so that the maximum extent will be displayed
+ *
+ */
+ this.calculateExtent = function(ext){
+ var relation_px_x = this.getWidth() / this.getHeight();
+ var relation_px_y = this.getHeight() / this.getWidth();
+ var relation_bbox_x = ext.extentx / ext.extenty;
+ if(relation_bbox_x <= relation_px_x){
+ ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
+ ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
+ }
+ if(relation_bbox_x > relation_px_x){
+ ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
+ ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
+ }
+ this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
+ };
+
+
+ /**
+ * zoom the map with a zoomfactor and optional to x,y coords
+ *
+ * @param {boolean} in_ in = true, out = false
+ * @param {float} factor the zoomfactor 1 equals 100%
+ * @param {float} x center to x-position
+ * @param {float} y center to y-position
+ */
+ this.zoom = function(in_, factor, x, y){
+ factor = parseFloat(factor);
+ if (!in_) {
+ factor = 1 / factor;
+ }
+
+ var extent = this.getExtentInfos();
+ var distx = extent.maxx - extent.minx;
+ var disty = extent.maxy - extent.miny;
+
+
+ if(x && y){
+ var centerx = parseFloat(x);
+ var centery = parseFloat(y);
+ }
+ else{
+ var centerx = extent.minx + distx/2;
+ var centery = extent.miny + disty/2;
+ }
+
+
+ var new_distx = distx / factor;
+ var new_disty = disty / factor;
+ var minx = centerx - new_distx / 2;
+ var miny = centery - new_disty / 2;
+ var maxx = centerx + new_distx / 2;
+ var maxy = centery + new_disty / 2;
+ this.setExtent(minx,miny,maxx,maxy);
+ //Todo:
+ //setMapRequest!
+ };
+
+ /**
+ * set the extent of the wms
+ */
+ this.setExtent = function(minx,miny,maxx,maxy){
+ this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
+ };
+
+ /**
+ * get the srs of the mapObj
+ *
+ * @return srs as epsg:number
+ * @type string
+ */
+ this.getSRS = function(){
+ return this.epsg;
+ };
+
+ /**
+ * get all mapRequests
+ *
+ * @return array of mapRequests of this map object
+ * @type string[]
+ */
+ this.getMapRequests = function(){
+ var allRequests = [];
+ //loop through all wms to get the mapRequests
+ for(var i=0; i<this.wms.length; i++){
+ var currentRequest = this.wms[i].getMapRequest(this);
+ if(currentRequest){
+ allRequests.push(currentRequest);
+ }
+ }
+ if(allRequests.length > 0){
+ return allRequests;
+ }
+ return false;
+ };
+
+ /**
+ * Return the map URL of the WMS at index i
+ * @param {Object} currentWmsIndex
+ */
+ this.getMapUrl = function (i, ii) {
+ var currentWms = this.wms[ii];
+ var validLayers = currentWms.getLayers(this);
+ var layerNames = validLayers.join(",");
+
+ url = currentWms.wms_getmap;
+ url += mb_getConjunctionCharacter(currentWms.wms_getmap);
+
+ if (currentWms.wms_version == "1.0.0") {
+ url += "WMTVER=" + currentWms.wms_version + "&REQUEST=map&";
+ }
+ else {
+ url += "VERSION=" + currentWms.wms_version + "&REQUEST=GetMap&SERVICE=WMS&";
+ }
+
+ url += "LAYERS=" + layerNames + "&";
+ url += "STYLES=";
+ var layer = layerNames.split(",");
+ for (var j = 0; j < layer.length; j++){
+ if (j > 0) {
+ url += ",";
+ }
+ if (currentWms.getCurrentStyleByLayerName(layer[j]) !== false) {
+ url += currentWms.getCurrentStyleByLayerName(layer[j]);
+ }
+ }
+ url += "&";
+ url += "SRS=" + this.epsg + "&";
+ url += "BBOX=" + this.extent + "&";
+ url += "WIDTH=" + this.width + "&";
+ url += "HEIGHT=" + this.height + "&";
+ url += "FORMAT=" + currentWms.gui_wms_mapformat + "&";
+ url += "BGCOLOR=0xffffff&";
+
+ if (currentWms.gui_wms_mapformat.search(/gif/i)>-1 ||
+ currentWms.gui_wms_mapformat.search(/png/i)>-1) {
+ url += "TRANSPARENT=TRUE&";
+ }
+
+ url += "EXCEPTIONS=" + currentWms.gui_wms_exceptionformat + "&";
+
+ // add vendor-specific
+ for (var v = 0; v < mb_vendorSpecific.length; v++) {
+ var vendorSpecificString = eval(mb_vendorSpecific[v]);
+ // if eval doesn't evaluate a function, the result is undefined.
+ // Sometimes it is necessary not to evaluate a function, for
+ // example if you want to change a variable from the current
+ // scope (see mod_addSLD.php)
+ if (typeof(vendorSpecificString) != "undefined") {
+ url += vendorSpecificString + "&";
+ }
+ }
+ // add Filter
+ if (currentWms.wms_filter !== ""){
+ url += "&SLD=" + currentWms.wms_filter +"?id="+ mb_styleID + "&";
+ }
+ // add sld
+ if(currentWms.gui_wms_sldurl !== ""){
+ url += "&SLD=" + escape(currentWms.gui_wms_sldurl) + "&";
+ }
+ return url;
+ }
+
+ /**
+ * get all featureInfoRequests
+ *
+ * @member mb_mapObj_const
+ * @param float x the x-value of the click position in pixel
+ * @param float y the y-value of the click position in pixel
+ * @return array of all featureInfoRequests of this map object
+ * @type string[]
+ */
+ this.getFeatureInfoRequests = function(clickPoint){
+ var allRequests = [];
+ //loop through all wms to get the FeatureInfoRequests
+ for(var i=0; i<this.wms.length; i++){
+ var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+ if(currentRequest){
+ allRequests.push(currentRequest);
+ }
+ }
+ if(allRequests.length > 0){
+ return allRequests;
+ }
+ return false;
+ };
+
+ /**
+ * calculation of the mapscale
+ *
+ * @member mb_mapObj_const
+ * @return scale
+ * @type integer
+ */
+ this.getScale = function(){
+ var scale;
+ var bbox = this.extent.split(",");
+ var xtenty;
+ if(this.epsg=="EPSG:4326"){
+ var pxLenx = (parseFloat(bbox[2])-parseFloat(bbox[0]))/this.width;
+ var pxLeny = (parseFloat(bbox[3])-parseFloat(bbox[1]))/this.height;
+ var lat_from = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2)*Math.PI)/180;
+ var lat_to = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2+pxLeny)*Math.PI)/180;
+ var lon_from = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2)*Math.PI)/180;
+ var lon_to = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2+pxLeny)*Math.PI)/180;
+ var dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to));
+ scale = (dist/Math.SQRT2) * (mb_resolution * 100);
+ }else{
+ xtenty = parseFloat(bbox[3]) - parseFloat(bbox[1]);
+ scale = (xtenty / this.height) * (mb_resolution * 100);
+ }
+ return Math.round(scale);
+ };
+ /**
+ * move a wms or layer
+ *
+ * @param int wms_id id of wms to move
+ * @param int layer_id id of layer to move
+ * @return true of successful
+ * @type boolean
+ */
+ this.move = function(wms_id, layer_id, moveUp){
+ var i,j;
+ for(i=0;i<this.wms.length;i++){
+ if (wms_id == this.wms[i].wms_id) {
+ break;
+ }
+ }
+
+ //check if only one wms is affected?
+ if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
+ return this.wms[i].moveLayer(layer_id, moveUp);
+ }
+
+ //else swap wms
+ j = i + (moveUp?-1:1);
+ if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
+ return false;
+ }
+
+ upper = this.wms[i];
+ this.wms[i] = this.wms[j];
+ this.wms[j] = upper;
+ var upperLayers = this.layers[i];
+ var upperStyles = this.styles[i];
+ var upperQuerylayers = this.querylayers[i];
+ this.layers[i] = this.layers[j];
+ this.styles[i] = this.styles[j];
+ this.querylayers[i] = this.querylayers[j];
+ this.layers[j] = upperLayers;
+ this.styles[j] = upperStyles;
+ this.querylayers[j] = upperQuerylayers;
+
+ return true;
+ };
+
+ eventAfterMapObjectConstruction.trigger();
+}
\ No newline at end of file
Added: trunk/mapbender/http/javascripts/wms.js
===================================================================
--- trunk/mapbender/http/javascripts/wms.js (rev 0)
+++ trunk/mapbender/http/javascripts/wms.js 2008-06-23 16:13:23 UTC (rev 2544)
@@ -0,0 +1,777 @@
+/*
+ * $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+ * 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.
+ */
+
+//global variables
+var wms = [];
+var wms_layer_count = 0;
+
+/**
+ * global function to add wms to the wms-object
+ *
+ * @param {String} wms_id the unique id of the wms
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {Integer} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ */
+function add_wms(
+ wms_id,
+ wms_version,
+ wms_title,
+ wms_abstract,
+ wms_getmap,
+ wms_getfeatureinfo,
+ wms_getlegendurl,
+ wms_filter,
+ gui_wms_mapformat,
+ gui_wms_featureinfoformat,
+ gui_wms_exceptionformat,
+ gui_wms_epsg,
+ gui_wms_visible,
+ gui_wms_opacity,
+ gui_wms_sldurl){
+ wms[wms.length] = new wms_const(
+ wms_id,
+ wms_version,
+ wms_title,
+ wms_abstract,
+ wms_getmap,
+ wms_getfeatureinfo,
+ wms_getlegendurl,
+ wms_filter,
+ gui_wms_mapformat,
+ gui_wms_featureinfoformat,
+ gui_wms_exceptionformat,
+ gui_wms_epsg,
+ parseInt(gui_wms_visible, 10),
+ parseInt(gui_wms_opacity),
+ parseInt(gui_wms_opacity),
+ gui_wms_sldurl);
+ wms_layer[wms.length - 1] = [];
+}
+/**
+ * @class A class representing the wms
+ *
+ * @constructor
+ * @param {String} wms_id the unique id of the wms
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {String} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ *
+ */
+function wms_const(
+ wms_id,
+ wms_version,
+ wms_title,
+ wms_abstract,
+ wms_getmap,
+ wms_getfeatureinfo,
+ wms_getlegendurl,
+ wms_filter,
+ gui_wms_mapformat,
+ gui_wms_featureinfoformat,
+ gui_wms_exceptionformat,
+ gui_wms_epsg,
+ gui_wms_visible,
+ gui_wms_opacity,
+ gui_wms_sldurl){
+
+ if (!wms_id) {
+ var id_ok = false;
+ while (id_ok === false) {
+ wms_id = "a"+Math.round(10000*Math.random());
+ id_ok = true;
+ for (var i=0; i < wms.length && id_ok === true; i++) {
+ if (wms_id == wms[i].wms_id) {
+ id_ok = false;
+ }
+ }
+ }
+ }
+
+ this.wms_id = wms_id;
+ this.wms_version = wms_version;
+ this.wms_title = wms_title;
+ this.wms_abstract = wms_abstract;
+ this.wms_getmap = wms_getmap;
+ this.wms_getfeatureinfo = wms_getfeatureinfo;
+ this.wms_getlegendurl = wms_getlegendurl;
+ this.wms_filter = wms_filter;
+ this.data_type = [];
+ this.data_format = [];
+ this.objLayer = [];
+ this.gui_wms_mapformat = gui_wms_mapformat;
+ this.gui_wms_featureinfoformat = gui_wms_featureinfoformat;
+ this.gui_wms_exceptionformat = gui_wms_exceptionformat;
+ this.gui_wms_epsg = gui_wms_epsg;
+ this.gui_wms_visible = gui_wms_visible;
+ this.gui_epsg = [];
+ this.gui_minx = [];
+ this.gui_miny = [];
+ this.gui_maxx = [];
+ this.gui_maxy = [];
+
+ // opacity version
+ this.gui_wms_mapopacity = gui_wms_opacity/100;
+ // sld version
+ this.gui_wms_sldurl = gui_wms_sldurl;
+}
+
+/**
+ * rephrases the mapRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms
+ * @return mapRequest, i.e. onlineresource + params
+ * @type String
+ */
+wms_const.prototype.getMapRequest = function(mapObj){
+ //check visible layers first
+ var layers = this.getLayers(mapObj);
+ if(!layers){
+ return false;
+ }
+
+ var rq = this.wms_getmap;
+ rq += mb_getConjunctionCharacter(this.wms_getmap);
+ if(this.wms_version === "1.0.0"){
+ rq += "WMTVER=" + this.wms_version + "&REQUEST=map";
+ }
+ else{
+ rq += "VERSION=" + this.wms_version + "&REQUEST=getMap&SERVICE=WMS";
+ }
+
+ rq += "&LAYERS=" + layers.join(",");
+ rq += "&WIDTH=" + mapObj.getWidth();
+ rq += "&HEIGHT=" + mapObj.getHeight();
+ rq += "&SRS=" + mapObj.getSRS();
+ rq += "&BBOX=" + mapObj.getExtent();
+ rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+ rq += "&FORMAT=" + this.gui_wms_mapformat;
+ rq += "&EXCEPTIONS=" + this.gui_wms_exceptionformat;
+ //Todo: error occurs:
+ //var throwNotice = new Mb_notice("getMapRequest: " + rq);
+ //window.console.log("getMapRequest: " + rq);
+ return rq;
+};
+
+
+/**
+ * rephrases the featureInfoRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms
+ * @param {Point} clickPoint map-click position {@link Point}
+ * @return featureInfoRequest, onlineresource + params
+ * @type string
+ */
+wms_const.prototype.getFeatureInfoRequest = function(mapObj, clickPoint){
+
+ //check layers and querylayers first
+ var layers = this.getLayers(mapObj);
+ var querylayers = this.getQuerylayers(mapObj);
+
+ if(!layers || !querylayers){
+ return false;
+ }
+
+ var rq = this.wms_getfeatureinfo;
+ rq += mb_getConjunctionCharacter(this.wms_getfeatureinfo);
+ if(this.wms_version === "1.0.0"){
+ rq += "WMTVER=" + this.wms_version + "&REQUEST=feature_info";
+ }
+ else{
+ rq += "VERSION=" + this.wms_version + "&REQUEST=GetFeatureInfo&SERVICE=WMS";
+ }
+
+ rq += "&LAYERS=" + layers.join(",");
+ rq += "&QUERY_LAYERS=" + querylayers.join(",");
+ rq += "&WIDTH=" + mapObj.getWidth();
+ rq += "&HEIGHT=" + mapObj.getHeight();
+ rq += "&SRS=" + mapObj.getSRS();
+ rq += "&BBOX=" + mapObj.getExtent();
+ rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+ rq += "&FORMAT=" + this.gui_wms_mapformat;
+ rq += "&INFO_FORMAT=" + this.gui_wms_featureinfoformat;
+ rq += "&EXCEPTIONS=application/vnd.ogc.se_xml";
+ rq += "&X=" + clickPoint.x;
+ rq += "&Y=" + clickPoint.y;
+ //console.log(rq);
+ return rq;
+};
+
+/**
+ * sets Opacity of WMS
+ *
+ * @param {Integer} new opacity percentage value
+ */
+wms_const.prototype.setOpacity = function(opacity){
+ //calc new opacity
+ this.gui_wms_mapopacity = parseInt(opacity)/100;
+ if(this.gui_wms_mapopacity>1||isNaN(this.gui_wms_mapopacity))
+ this.gui_wms_mapopacity=1;
+ if(this.gui_wms_mapopacity<0)
+ this.gui_wms_mapopacity=0;
+
+ if (this.gui_wms_visible > 0) {
+
+ //get div id
+ var divId = null;
+ for (var i=0; i < wms.length; i++) {
+ if (this.wms_id == wms[i].wms_id) {
+ var divId = 'div_'+i;
+ break;
+ }
+ }
+ if(!divId)
+ return;
+
+ //TODO: check if mapframe1 is the right mapframe
+ wmsImage = parent.mapframe1.document.getElementById(divId);
+ if (wmsImage != null) {
+ wmsImage.style.opacity = this.gui_wms_mapopacity;
+ wmsImage.style.MozOpacity = this.gui_wms_mapopacity;
+ wmsImage.style.KhtmlOpacity = this.gui_wms_mapopacity;
+ wmsImage.style.filter = "alpha(opacity=" + this.gui_wms_mapopacity*100 + ")";
+ }
+ }
+}
+
+/**
+ * get all visible layers
+ *
+ * @return array of layernames
+ * @type string[]
+ */
+wms_const.prototype.getLayers = function(mapObj){
+
+ try {
+ //visibility of the wms
+ var wmsIsVisible = (this.gui_wms_visible > 0);
+ if(!wmsIsVisible){
+ return false;
+ }
+ visibleLayers = [];
+ for(var i=0; i< this.objLayer.length; i++){
+ var isVisible = (this.objLayer[i].gui_layer_visible === 1);
+ var hasNoChildren = (!this.objLayer[i].has_childs);
+ if (isVisible && hasNoChildren){
+ if(this.objLayer[i].checkScale(mapObj)){
+ //console.log("checkLayer: " + this.objLayer[i].layer_name);
+ visibleLayers.push(this.objLayer[i].layer_name);
+ }
+ }
+ }
+ if(visibleLayers.length === 0){
+ return false;
+ }
+ return visibleLayers;
+ }
+ catch (e) {
+ alert(e);
+ }
+};
+
+/**
+ * get the actual style of all visible layers
+ *
+ * @return commaseparated list of actual layerstyles
+ * @type string
+ */
+wms_const.prototype.getLayerstyles = function(mapObj){
+ var layers = this.getLayers(mapObj);
+ var layerstyles = '';
+ var styles = [];
+ if(layers){
+ for(i = 0; i < layers.length; i++){
+ var style = this.getCurrentStyleByLayerName(layers[i]);
+ if(!style){
+ style = '';
+ }
+ styles.push(style);
+ }
+ return styles;
+ }
+ return false;
+};
+
+/**
+ * check if layer is parentLayer
+ *
+ * @param layername
+ * @return the parent value of the given layer
+ * @type integer
+ */
+wms_const.prototype.checkLayerParentByLayerName = function(layername){
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name == layername){
+ return this.objLayer[i].layer_parent;
+ }
+ }
+};
+
+/**
+ * get the title of the current layer
+ *
+ * @param layername
+ * @return the title of the given layer
+ * @type string
+ */
+wms_const.prototype.getTitleByLayerName = function(layername){
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name == layername){
+ return this.objLayer[i].layer_title;
+ }
+ }
+};
+
+/**
+ * get the current style of the layer
+ *
+ * @param layername
+ * @return the stylename of the given layer
+ * @type string
+ */
+wms_const.prototype.getCurrentStyleByLayerName = function(layername){
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name == layername){
+ if(this.objLayer[i].gui_layer_style === '' || this.objLayer[i].gui_layer_style === null){
+ return false;
+ }
+ else{
+ return this.objLayer[i].gui_layer_style;
+ }
+ }
+ }
+};
+
+/**
+ * get the legendurl of the gui layer style
+ *
+ * @param stylename
+ * @return the legendurl of the given style
+ * @type string
+ */
+wms_const.prototype.getLegendUrlByGuiLayerStyle = function(layername,guiLayerStyle){
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name == layername){
+ if(this.objLayer[i].layer_style.length === 0){
+ return false;
+ }
+ for(var k=0; k< this.objLayer[i].layer_style.length; k++){
+ if(this.objLayer[i].layer_style[k].name == guiLayerStyle){
+ var legendUrl = this.objLayer[i].layer_style[k].legendurl;
+ if (this.gui_wms_sldurl !== "") {
+ legendUrl += "&SLD="+escape(this.gui_wms_sldurl);
+ }
+ if(legendUrl !=='' && legendUrl !== null && typeof(legendUrl) != 'undefined'){
+ return legendUrl;
+ }
+ else {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return false;
+};
+
+/**
+ * get all querylayers
+ *
+ * @return array of layernames
+ * @type string[]
+ */
+wms_const.prototype.getQuerylayers = function(){
+ queryLayers = [];
+ for(var i=0; i< this.objLayer.length; i++){
+ if(this.objLayer[i].gui_layer_querylayer === 1 && ! this.objLayer[i].has_childs ){
+ queryLayers.push(this.objLayer[i].layer_name);
+ }
+ }
+ if(queryLayers.length === 0){
+ return false;
+ }
+ return queryLayers;
+};
+
+/**
+ * get a layer Object by layer_pos
+ *
+ * @param int payer_pos layer_pos of layer you want to get
+ * @return object layer
+ */
+
+wms_const.prototype.getLayerByLayerPos = function(layer_pos){
+ for(var i=0;i<this.objLayer.length;i++){
+ if(this.objLayer[i].layer_pos == layer_pos) {
+ return this.objLayer[i];
+ }
+ }
+ return null;
+};
+/**
+ * get the state of sublayers from a specified layer
+ *
+ * @param int layer_id of the parent layer
+ * @param String type "visible" or "querylayer"
+ * @return int -1 if state differs else the state
+ */
+
+wms_const.prototype.getSublayerState = function(layer_id, type){
+ var i;
+ var state=-1,value;
+ for(i = 0; i < this.objLayer.length; i++){
+ if(this.objLayer[i].layer_id==layer_id) {
+ break;
+ }
+ }
+
+ //go throught sublayers
+ for(var j = i+1; j < this.objLayer.length; j++){
+ if(this.objLayer[i].parent_layer == this.objLayer[j].parent_layer) {
+ break;
+ }
+ if(type == "visible") {
+ value = this.objLayer[j].gui_layer_visible;
+ }
+ else if(type == "querylayer") {
+ value = this.objLayer[j].gui_layer_querylayer;
+ }
+ if(state == -1) {
+ state = value;
+ }
+ if(state != value) {
+ return -1;
+ }
+ }
+
+ return state;
+};
+/**
+ * handle change of visibility / quaryability of a layer
+ *
+ * @param string layer_name of layer to handle
+ * @param string type of change ("visible" or "querylayer")
+ * @param int value of the change
+ */
+wms_const.prototype.handleLayer = function(layer_name, type, value){
+ var i;
+ for(i = 0; i < this.objLayer.length; i++){
+ if(this.objLayer[i].layer_name==layer_name) {
+ break;
+ }
+ }
+
+ //Set visibility/queryability of Layer and Sublayers
+ for(var j = i; j < this.objLayer.length; j++){
+ if (i != j && this.objLayer[i].layer_parent >= this.objLayer[j].layer_parent) {
+ break;
+ }
+ if(type == "visible") {
+ this.objLayer[j].gui_layer_visible = parseInt(value, 10);
+ }
+ else if(type=="querylayer") {
+ this.objLayer[j].gui_layer_querylayer = parseInt(value, 10);
+ }
+ }
+
+ //Update visibility/queryability of parent layer
+ var parentLayer = this.getLayerByLayerPos(this.objLayer[i].layer_parent);
+ if(parentLayer){
+ var state = this.getSublayerState(parentLayer.layer_id, type);
+ if(state!=-1){
+ if(type == "visible") {
+ this.objLayer[j].gui_layer_visible = state;
+ }
+ else if(type=="querylayer") {
+ this.objLayer[j].gui_layer_querylayer = state;
+ }
+ }
+ }
+};
+
+
+/**
+ * move a layer (with his sublayers) up or down
+ *
+ * @param int layerId layer_id of layer to move
+ * @param boolean moveUp true to move up or false to move down
+ * @return boolean success
+ */
+
+wms_const.prototype.moveLayer = function(layerId, moveUp){
+ var iLayer=-1;
+ var i;
+
+ //find layer to move
+ for(i=0;i<this.objLayer.length;i++){
+ if(this.objLayer[i].layer_id==layerId){
+ iLayer=i;
+ break;
+ }
+ }
+ if(iLayer==-1) {
+ return false;
+ }
+
+ var upperLayer = -1;
+ var lowerLayer = -1;
+
+ //find layer to swap position with
+ var parentLayer = this.objLayer[iLayer].layer_parent;
+ if(moveUp){
+ lowerLayer = iLayer;
+
+ //find previous layer on same level
+ for(i=iLayer-1;i>0;i--){
+ if(parentLayer == this.objLayer[i].layer_parent){
+ upperLayer = i;
+ break;
+ }
+ }
+ if(upperLayer == -1){
+ //alert("The Layer you selected is already on top of parent Layer/WMS");
+ return false;
+ }
+ }
+ else{
+ upperLayer = iLayer;
+
+ //find next layer on same level
+ for(i=iLayer+1;i<this.objLayer.length;i++){
+ if(parentLayer == this.objLayer[i].layer_parent){
+ lowerLayer = i;
+ break;
+ }
+ }
+ if(lowerLayer == -1){
+ //alert("The Layer you selected is already on bottom of parent Layer/WMS");
+ return false;
+ }
+ }
+
+ //calc number of layers to move down
+ var layersDown = lowerLayer - upperLayer;
+
+ //get number of layers to move up
+ for(i=lowerLayer+1; i<this.objLayer.length; i++){
+ if(parentLayer == this.objLayer[i].layer_parent){
+ break;
+ }
+ }
+ var layersUp = i - lowerLayer;
+
+ //do moving
+ var temp = [];
+ for(i=0;i<layersDown+layersUp;i++){
+ temp[temp.length]=this.objLayer[upperLayer+i];
+ }
+ for(i=0;i<layersUp;i++){
+ this.objLayer[upperLayer+i]=temp[i+layersDown];
+ }
+ for(i=0;i<layersDown;i++){
+ this.objLayer[upperLayer+layersUp+i]=temp[i];
+ }
+
+ return true;
+};
+
+function wms_add_data_type_format(datatype,dataformat){
+ var insertDataFormat = true;
+ for (var i = 0 ; i < wms[wms.length-1].data_type.length ; i ++) {
+ if (wms[wms.length-1].data_type[i] == datatype && wms[wms.length-1].data_format[i] == dataformat) {
+ insertDataFormat = false;
+ }
+ }
+ if (insertDataFormat === true) {
+ wms[wms.length-1].data_type[wms[wms.length-1].data_type.length] = datatype;
+ wms[wms.length-1].data_format[wms[wms.length-1].data_format.length] = dataformat;
+ }
+}
+function wms_addSRS(epsg,minx,miny,maxx,maxy){
+ wms[wms.length-1].gui_epsg[wms[wms.length-1].gui_epsg.length] = epsg;
+ wms[wms.length-1].gui_minx[wms[wms.length-1].gui_minx.length] = minx;
+ wms[wms.length-1].gui_miny[wms[wms.length-1].gui_miny.length] = miny;
+ wms[wms.length-1].gui_maxx[wms[wms.length-1].gui_maxx.length] = maxx;
+ wms[wms.length-1].gui_maxy[wms[wms.length-1].gui_maxy.length] = maxy;
+}
+function wms_addLayerStyle(styleName, styleTitle, count, layerCount, styleLegendUrl, styleLegendUrlFormat){
+ var currentLayer = wms[wms.length-1].objLayer[layerCount];
+ if (currentLayer) {
+ currentLayer.layer_style[count] = {};
+ currentLayer.layer_style[count].name = styleName;
+ currentLayer.layer_style[count].title = styleTitle;
+ currentLayer.layer_style[count].legendurl = styleLegendUrl;
+ currentLayer.layer_style[count].legendurlformat = styleLegendUrlFormat;
+ }
+}
+//TODO: add layerstyle handling....
+//layer
+function wms_add_layer(
+ layer_parent,
+ layer_uid,
+ layer_name,
+ layer_title,
+ layer_dataurl_href,
+ layer_pos,
+ layer_queryable,
+ layer_minscale,
+ layer_maxscale,
+ layer_metadataurl,
+ gui_layer_wms_id,
+ gui_layer_status,
+ gui_layer_style,
+ gui_layer_selectable,
+ gui_layer_visible,
+ gui_layer_queryable,
+ gui_layer_querylayer,
+ gui_layer_minscale,
+ gui_layer_maxscale,
+ gui_layer_wfs_featuretype){
+
+ wms[wms.length-1].objLayer[wms[wms.length-1].objLayer.length] = new wms_layer(
+ layer_parent,
+ layer_uid,
+ layer_name,
+ layer_title,
+ layer_dataurl_href,
+ layer_pos,
+ layer_queryable,
+ layer_minscale,
+ layer_maxscale,
+ layer_metadataurl,
+ gui_layer_wms_id,
+ gui_layer_status,
+ gui_layer_style,
+ parseInt(gui_layer_selectable, 10),
+ parseInt(gui_layer_visible, 10),
+ parseInt(gui_layer_queryable, 10),
+ parseInt(gui_layer_querylayer, 10),
+ parseInt(gui_layer_minscale, 10),
+ parseInt(gui_layer_maxscale, 10),
+ gui_layer_wfs_featuretype );
+ var parentLayer = wms[wms.length-1].getLayerByLayerPos(parseInt(layer_parent, 10));
+ if(parentLayer) {
+ parentLayer.has_childs = true;
+ }
+}
+function layer_addEpsg(epsg,minx,miny,maxx,maxy){
+ var j = wms[wms.length-1].objLayer.length-1;
+ var k = wms[wms.length-1].objLayer[j].layer_epsg.length;
+ var currentLayer = wms[wms.length-1].objLayer[j];
+ currentLayer.layer_epsg[k]={};
+ currentLayer.layer_epsg[k].epsg = epsg;
+ currentLayer.layer_epsg[k].minx = minx;
+ currentLayer.layer_epsg[k].miny = miny;
+ currentLayer.layer_epsg[k].maxx = maxx;
+ currentLayer.layer_epsg[k].maxy = maxy;
+}
+function wms_layer(
+ layer_parent,
+ wms_layer_uid,
+ layer_name,
+ layer_title,
+ layer_dataurl_href,
+ layer_pos,
+ layer_queryable,
+ layer_minscale,
+ layer_maxscale,
+ layer_metadataurl,
+ gui_layer_wms_id,
+ gui_layer_status,
+ gui_layer_style,
+ gui_layer_selectable,
+ gui_layer_visible,
+ gui_layer_queryable,
+ gui_layer_querylayer,
+ gui_layer_minscale,
+ gui_layer_maxscale,
+ gui_layer_wfs_featuretype){
+ this.layer_id = wms_layer_count;
+ this.layer_uid = wms_layer_uid;
+ this.layer_parent = layer_parent;
+ this.layer_name = layer_name;
+ this.layer_title = layer_title;
+ this.layer_dataurl_href = layer_dataurl_href;
+ this.layer_pos = layer_pos;
+ this.layer_queryable = layer_queryable;
+ this.layer_minscale = layer_minscale;
+ this.layer_maxscale = layer_maxscale;
+ this.layer_metadataurl = layer_metadataurl;
+ this.layer_epsg = [];
+ this.gui_layer_wms_id = gui_layer_wms_id;
+ this.gui_layer_status = gui_layer_status;
+ this.gui_layer_selectable = gui_layer_selectable;
+ this.gui_layer_visible = gui_layer_visible;
+ this.gui_layer_queryable = gui_layer_queryable;
+ this.gui_layer_querylayer = gui_layer_querylayer;
+ this.gui_layer_minscale = gui_layer_minscale;
+ this.gui_layer_maxscale = gui_layer_maxscale;
+ this.gui_layer_style = gui_layer_style;
+ this.gui_layer_wfs_featuretype = gui_layer_wfs_featuretype;
+ this.gui_layer_style = null;
+ this.has_childs = false;
+ this.layer_style = [];
+ wms_layer_count++;
+}
+/**
+ * check the scale of the layer
+ *
+ * @param Object mapObj the mapbender mapObject of the layer
+ * @return boolean if the layer is in scale or not
+ * @type boolean
+ */
+wms_layer.prototype.checkScale = function(mapObj){
+ var minScale = parseInt(this.gui_layer_minscale, 10);
+ var maxScale = parseInt(this.gui_layer_maxscale, 10);
+ var currentScale = parseInt(mapObj.getScale(), 10);
+ if(minScale === 0 && maxScale === 0){
+ return true;
+ }
+ if(minScale > currentScale || (maxScale !== 0 && maxScale < currentScale)) {
+ return false;
+ }
+ return true;
+};
+/**
+ * set visibility of the layer
+ * @param boolean visible visibility on/off
+ */
+wms_layer.prototype.setVisible = function(visible){
+ this.gui_layer_visible = parseInt(visible, 10);
+ //console.log("setVisible(%i) for Layer %s",visible, this.layer_name);
+};
+
+/**
+ * set queryability of the layer
+ * @param boolean queryable queryability on/off
+ */
+
+wms_layer.prototype.setQueryable = function(queryable){
+ this.gui_layer_querylayer = parseInt(queryable, 10);
+ //console.log("setQueryable(%i) for Layer %s",queryable, this.layer_name);
+};
\ No newline at end of file
More information about the Mapbender_commits
mailing list