[Mapbender-commits] r3111 - branches/noframes/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 3 09:46:14 EDT 2008
Author: christoph
Date: 2008-10-03 09:46:14 -0400 (Fri, 03 Oct 2008)
New Revision: 3111
Modified:
branches/noframes/http/javascripts/map.js
branches/noframes/http/javascripts/map_obj.js
Log:
Modified: branches/noframes/http/javascripts/map.js
===================================================================
--- branches/noframes/http/javascripts/map.js 2008-10-03 13:30:49 UTC (rev 3110)
+++ branches/noframes/http/javascripts/map.js 2008-10-03 13:46:14 UTC (rev 3111)
@@ -7,6 +7,27 @@
var mb_end_y = 0;
/**
+ * @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;
+}
+
+/**
* @deprecated
*/
function mb_execloadWmsSubFunctions(){
@@ -51,315 +72,63 @@
}
});
-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));
}
-
+/**
+ * @deprecated
+ */
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;
+ new Mb_warning("The function mb_mapObjremoveWMS is deprecated.");
+ return mb_mapObj[objind].removeWms(wmsind);
+};
- 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;
- }
- }
-}
+/**
+ * @deprecated
+ */
function setMapRequest(frameName){
- var functionName = 'setMapRequest';
-
- var ret = eventBeforeMapRequest.trigger({frameName:frameName}, "AND");
- if (ret === false) {
- return true;
- }
-
- var ts = mb_timestamp();
- var myMapId = [];
- for (var i=0; i < mb_mapObj.length; i++){
- var currentMapObject = mb_mapObj[i];
- if (currentMapObject.elementName != 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;
- }
- myMapId.push("map_"+ii);
-
- newMapRequest += getLayerHtmlCode(frameName, i, ii);
-
- }
- writeTag(mb_mapObj[i].frameName, mb_mapObj[i].elementName+"_maps", newMapRequest);
- }
- eventAfterMapRequest.trigger({
- "frameName": frameName,
- "myMapId": myMapId.join(",")
- });
-/*
- for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
- eval(mb_MapRequestSubFunctions[i]);
- }
-*/
+ new Mb_warning("The function setMapRequest is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].setMapRequest();
}
-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 = "";
- if (newMapURL) {
- 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;
-}
-
+/**
+ * @deprecated
+ */
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;
+ new Mb_warning("The function setSingleMapRequest is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].setSingleMapRequest(wms_id);
}
-
+/**
+ * @deprecated
+ */
function mb_restateLayers(frameName,wms_id){
- //alert(frameName + " / " + wms_id);
+ new Mb_warning("The function mb_restateLayers is deprecated.");
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;
- }
- }
+ mb_mapObj[ind].restateLayers(wms_id);
}
+/**
+ * @deprecated
+ */
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;
+ new Mb_warning("The function mb_checkScale is deprecated.");
+ return mb_mapObj[mObj].checkScale(wmsObj);
}
+/**
+ * @deprecated
+ */
function setFeatureInfoRequest(fName,x,y, path) {
+ new Mb_warning("The function setFeatureInfoRequest is deprecated.");
+
+/*
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){
@@ -460,197 +229,84 @@
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) {
+ new Mb_warning("The function zoom is deprecated.");
var obj = getMapObjByName(frameName);
- if(x && y){
- obj.zoom(in_, factor, x, y);
- }
- else{
- obj.zoom(in_, factor, false, false);
- }
- setMapRequest(frameName);
+ return obj.zoom(in_, factor, x, y);
}
-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);
+/**
+ * @deprecated
+ */
+function mb_panMap(frameName,dir){
+ new Mb_warning("The function mb_panMap is deprecated.");
+ var obj = getMapObjByName(frameName);
+ return obj.pan(dir);
}
+/**
+ * @deprecated
+ */
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++;
- }
- }
- }
- }
- }
+ new Mb_warning("The function handleSelectedLayer is deprecated.");
+ var obj = getMapObjByName(frameName);
+ for (var ii = 0; ii < obj.wms.length; ii++) {
+ if (obj.wms[ii].wms_title == wms_title) {
+ obj.wms[ii].handleLayer(layerName, type, status);
+ obj.restateLayers(obj.wms[ii].wms_id);
}
}
- 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');
- }
- }
+/**
+ * @deprecated
+ */
+function handleSelectedLayer_array(frameName, array_wms, array_layer, type, status){
+ new Mb_warning("The function handleSelectedLayer_array is deprecated.");
+ var obj = getMapObjByName(frameName);
+ changedWms = [];
+ for (var i = 0; i < array_wms.length; i++) {
+ var wmsWillBeUpdated = false;
+ for (var ii = 0; ii < obj.wms.length; ii++) {
+ if (obj.wms[ii].wms_id == array_wms[i]) {
+ obj.wms[ii].handleLayer(array_layer[i], type, status);
+ obj.restateLayers(obj.wms[ii].wms_id);
+ if (!wmsWillBeUpdated) {
+ changedWms.push(obj.wms[ii].wms_id);
+ wmsWillBeUpdated = true;
+ }
}
}
}
+ for (aWms in changedWms) {
+ obj.setSingleMapRequest(aWms);
+ }
}
+/**
+ * @deprecated
+ */
function makeClickPos2RealWorldPos(frameName, myClickX, myClickY) {
+ new Mb_warning("The function makeClickPos2RealWorldPos is deprecated.");
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];
+ var newPoint = mb_mapObj[ind].convertPixelToReal(new Point(myClickX, myClickY));
+ return [newPoint.x, newPoint.y]
}
+/**
+ * @deprecated
+ */
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))];
+ new Mb_warning("The function makeRealWorld2mapPos is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ var aPoint = mb_mapObj[ind].convertRealToPixel(new Point(rw_posx, rw_posy));
+ return [aPoint.x, aPoint.y];
}
// function for object-identification
@@ -669,96 +325,62 @@
}
return false;
}
+
+/**
+ * @deprecated
+ */
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;
- }
- }
+ new Mb_warning("The function getWMSIDByTitle is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].getWmsIdByTitle(wms_title);
}
+
+/**
+ * @deprecated
+ */
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;
- }
- }
+ new Mb_warning("The function getWMSIndexById is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].getWmsIndexdById(wms_id);
}
-//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;
-}
-
+/**
+ * @deprecated
+ */
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);
+ new Mb_warning("The function mb_repaintScale is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].repaintScale(x, y, scale);
}
+
+/**
+ * @deprecated
+ */
function mb_repaint(frameName,minx,miny,maxx,maxy){
- var ind = getMapObjIndexByName(frameName);
- mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
- setMapRequest(frameName);
+ new Mb_warning("The function mb_repaint is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ mb_mapObj[ind].extent = minx + "," + miny + "," + maxx + "," + maxy;
+ setMapRequest(frameName);
}
-/*
+
+/**
+ * @deprecated
+ */
+function mb_getScale(frameName) {
+ new Mb_warning("The function mb_getScale is deprecated.");
+ var ind = getMapObjIndexByName(frameName);
+ return mb_mapObj[ind].getScale();
+}
+
+/**
* 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){
+ new Mb_warning("The function mb_calculateExtent is deprecated.");
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;
-}
-
+}
\ No newline at end of file
Modified: branches/noframes/http/javascripts/map_obj.js
===================================================================
--- branches/noframes/http/javascripts/map_obj.js 2008-10-03 13:30:49 UTC (rev 3110)
+++ branches/noframes/http/javascripts/map_obj.js 2008-10-03 13:46:14 UTC (rev 3111)
@@ -6,6 +6,73 @@
var mb_mapObj = [];
function mb_mapObj_const(frameName, elementName, width, height, wms_index){
+
+ /**
+ * 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 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);
+ };
+
+ /**
+ * 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);
+ return ext;
+ };
+
this.width = width;
this.height = height;
this.frameName = frameName;
@@ -14,16 +81,16 @@
this.styles = [];
this.querylayers = [];
this.geom = "";
- this.gml = "";
+ 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++){
+ for (var i = 0; i < wms.length; i++) {
var isValidWms = (wms_index === null) || (wms_index == i);
if (isValidWms) {
this.wms[index] = wms[i];
@@ -31,7 +98,7 @@
index++;
}
}
-
+
//
// set list of visible layers, active querylayers
// and styles for each WMS in this map
@@ -41,39 +108,54 @@
var styles;
var layers;
var querylayers = "";
- for(i=0; i< this.wms.length; i++){
+ 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++){
+
+ 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 += ",";
+ 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 += "";
+ 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){
+ if (this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii > 0) {
+ if (cnt_querylayers > 0) {
querylayers += ",";
}
- querylayers += wms[i].objLayer[ii].layer_name;
+ 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);
+ var bbox_minx, bbox_miny, bbox_maxx, bbox_maxy;
+
+ for (var i = 0; i < wms[0].gui_epsg.length; i++) {
+ if (this.epsg == wms[0].gui_epsg[i]) {
+ bbox_minx = parseFloat(wms[0].gui_minx[i]);
+ bbox_miny = parseFloat(wms[0].gui_miny[i]);
+ bbox_maxx = parseFloat(wms[0].gui_maxx[i]);
+ bbox_maxy = parseFloat(wms[0].gui_maxy[i]);
+ }
+ }
+ var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+
+ this.calculateExtent(wmsExtent);
+ console.log("ext: %s, %s", this.frameName, this.extent);
+
this.mapURL = [];
if(this.frameName){
this.domElement = window.frames[this.frameName].document.getElementById(this.elementName);
@@ -84,51 +166,13 @@
this.domElement.style.width = this.width;
this.domElement.style.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
+ * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy
* @type string
*/
this.getExtent = function(){
@@ -138,44 +182,138 @@
/**
* get the extent as minx, maxx, miny, maxy
*
- * @return extent and additional informations of the mapObj
+ * @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]);
+ 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
- *
+ * Sets the list of layers, styles and querylayers for a specified WMS
*/
- 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;
+ this.restateLayers = function(wms_id){
+ for (var i = 0; i < this.wms.length; i++) {
+ if (this.wms[i].wms_id == wms_id) {
+ var currentWms = this.wms[i];
+ var cnt_layers = 0;
+ var cnt_querylayers = 0;
+ var layers = "";
+ var styles = "";
+ var querylayers = "";
+ for (var ii = 0; ii < currentWms.objLayer.length; ii++) {
+ var currentLayer = currentWms.objLayer[ii];
+ if (currentLayer.gui_layer_visible == 1 && !currentLayer.has_childs) {
+ if (cnt_layers > 0) {
+ layers += ",";
+ styles += ",";
+ }
+ layers += currentLayer.layer_name;
+ styles += "";
+ cnt_layers++;
+ }
+ if (currentLayer.gui_layer_querylayer == 1 && !currentLayer.has_childs) {
+ if (cnt_querylayers > 0) {
+ querylayers += ",";
+ }
+ querylayers += currentLayer.layer_name;
+ cnt_querylayers++;
+ }
+ }
+ this.layers[i] = layers;
+ this.querylayers[i] = querylayers;
+ this.styles[i] = styles;
+ }
}
- 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;
+ };
+
+ /**
+ *
+ * @param {Object} direction
+ */
+ this.pan = function (direction) {
+ var arrayBBox = this.extent.split(",");
+ var minx = parseFloat(arrayBBox[0]);
+ var miny = parseFloat(arrayBBox[1]);
+ var maxx = parseFloat(arrayBBox[2]);
+ var maxy = parseFloat(arrayBBox[3]);
+ var xtentx = maxx - minx;
+ var xtenty = maxy - miny;
+ var factor = 0.5;
+
+ switch (direction) {
+ case "NW" :
+ minx -= (xtentx * factor);
+ maxx -= (xtentx * factor);
+ miny += (xtenty * factor);
+ maxy += (xtenty * factor);
+ break;
+ case "N" :
+ miny += (xtenty * factor);
+ maxy += (xtenty * factor);
+ break;
+ case "NE" :
+ minx += (xtentx * factor);
+ maxx += (xtentx * factor);
+ miny += (xtenty * factor);
+ maxy += (xtenty * factor);
+ break;
+ case "E" :
+ minx += (xtentx * factor);
+ maxx += (xtentx * factor);
+ break;
+ case "SE" :
+ minx += (xtentx * factor);
+ maxx += (xtentx * factor);
+ miny -= (xtenty * factor);
+ maxy -= (xtenty * factor);
+ break;
+ case "S" :
+ miny -= (xtenty * factor);
+ maxy -= (xtenty * factor);
+ break;
+ case "SW" :
+ minx -= (xtentx * factor);
+ maxx -= (xtentx * factor);
+ miny -= (xtenty * factor);
+ maxy -= (xtenty * factor);
+ break;
+ case "W" :
+ minx -= (xtentx * factor);
+ maxx -= (xtentx * factor);
+ break;
}
- this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
+ this.extent = minx + "," + miny + "," + maxx + "," + maxy;
+ this.setMapRequest();
+
};
+ this.zoomFull = function () {
+
+ for (var i = 0; i < this.wms[0].gui_epsg.length; i++) {
+ if (this.epsg == this.wms[0].gui_epsg[i]) {
+ var bbox_minx = parseFloat(this.wms[0].gui_minx[i]);
+ var bbox_miny = parseFloat(this.wms[0].gui_miny[i]);
+ var bbox_maxx = parseFloat(this.wms[0].gui_maxx[i]);
+ var bbox_maxy = parseFloat(this.wms[0].gui_maxy[i]);
+ var wmsExtent = new Extent(bbox_minx, bbox_miny, bbox_maxx, bbox_maxy);
+ var newExtent = this.calculateExtent(wmsExtent);
+ this.repaint(new Point(newExtent.minx, newExtent.miny), new Point(newExtent.maxx, newExtent.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){
+ this.zoom = function(in_, factor, x, y){
factor = parseFloat(factor);
if (!in_) {
factor = 1 / factor;
@@ -183,41 +321,88 @@
var extent = this.getExtentInfos();
var distx = extent.maxx - extent.minx;
- var disty = extent.maxy - extent.miny;
+ var disty = extent.maxy - extent.miny;
- if(x && y){
+ if (x && y) {
var centerx = parseFloat(x);
var centery = parseFloat(y);
}
- else{
- var centerx = extent.minx + distx/2;
- var centery = extent.miny + disty/2;
+ 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!
- };
+ this.setExtent(minx, miny, maxx, maxy);
+ this.setMapRequest();
+ };
+
+ var performUnknownCalculation = function (value) {
+ return Math.pow(10,(
+ Math.round(
+ Math.log(value)/
+ Math.log(10)
+ )
+ ));
+ };
+
+ this.convertPixelToReal = function (aPoint) {
+ var arrayBBox = this.extent.split(",");
+ var minX = parseFloat(arrayBBox[0]);
+ var minY = parseFloat(arrayBBox[1]);
+ var maxX = parseFloat(arrayBBox[2]);
+ var maxY = parseFloat(arrayBBox[3]);
+ var xtentx = maxX - minX;
+ var xtenty = maxY - minY;
+ var deltaX = xtentx/this.width;
+ var deltaY = xtenty/this.height;
+ var roundx, roundy;
+
+ if(deltaX > 0){
+ roundx = 1/performUnknownCalculation(deltaX);
+ }
+ else{
+ roundx = performUnknownCalculation(deltaX);
+ }
+ if(deltaY > 0){
+ roundy = 1/performUnknownCalculation(deltaY);
+ }
+ else{
+ roundy = performUnknownCalculation(deltaY);
+ }
+ var posX = parseFloat(minX + (aPoint.x / width) * xtentx);
+ var posY = parseFloat(maxY - (aPoint.y / height) * xtenty);
+ posX = Math.round(posX * roundx) / roundx;
+ posY = Math.round(posY * roundy) / roundy;
+ return new Point(posX, posY);
+ };
+
/**
- * set the extent of the wms
+ * Convert real world coordinates to pixel coordinates
*/
- this.setExtent = function(minx,miny,maxx,maxy){
- this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
- };
+ this.convertRealToPixel = function (aPoint) {
+ var arrayBBox = this.extent.split(",");
+ var minX = parseFloat(arrayBBox[0]);
+ var minY = parseFloat(arrayBBox[1]);
+ var maxX = parseFloat(arrayBBox[2]);
+ var maxY = parseFloat(arrayBBox[3]);
+ return new Point(
+ Math.round((aPoint.x - minX) * this.width /(maxX - minX)),
+ Math.round((maxY - aPoint.y) * this.height/(maxY - minY))
+ );
+ };
/**
* get the srs of the mapObj
*
- * @return srs as epsg:number
+ * @return srs as epsg:number
* @type string
*/
this.getSRS = function(){
@@ -225,51 +410,51 @@
};
/**
- * get all mapRequests
+ * get all mapRequests
*
- * @return array of mapRequests of this map object
- * @type string[]
+ * @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++){
+ for (var i = 0; i < this.wms.length; i++) {
var currentRequest = this.wms[i].getMapRequest(this);
- if(currentRequest){
+ if (currentRequest) {
allRequests.push(currentRequest);
}
}
- if(allRequests.length > 0){
+ 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) {
+ this.getMapUrl = function(ii){
var currentWms = this.wms[ii];
var validLayers = currentWms.getLayers(this);
var layerNames = validLayers.join(",");
- url = currentWms.wms_getmap;
+ 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++){
+ for (var j = 0; j < layer.length; j++) {
if (j > 0) {
- url += ",";
+ url += ",";
}
if (currentWms.getCurrentStyleByLayerName(layer[j]) !== false) {
url += currentWms.getCurrentStyleByLayerName(layer[j]);
@@ -282,87 +467,314 @@
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&";
+
+ 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]);
+ 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 + "&";
+ if (currentWms.wms_filter !== "") {
+ url += "&SLD=" + currentWms.wms_filter + "?id=" + mb_styleID + "&";
}
// add sld
- if(currentWms.gui_wms_sldurl !== ""){
+ if (currentWms.gui_wms_sldurl !== "") {
url += "&SLD=" + escape(currentWms.gui_wms_sldurl) + "&";
}
return url;
}
-
+
/**
- * get all featureInfoRequests
+ * 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[]
+ * @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++){
+ for (var i = 0; i < this.wms.length; i++) {
var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
- if(currentRequest){
+ if (currentRequest) {
allRequests.push(currentRequest);
}
}
- if(allRequests.length > 0){
+ if (allRequests.length > 0) {
return allRequests;
}
return false;
};
/**
- * calculation of the mapscale
+ * calculation of the mapscale
*
* @member mb_mapObj_const
- * @return scale
- * @type integer
+ * @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]);
+ 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);
};
+
/**
+ *
+ */
+ this.checkScale = function(wmsIndex){
+ var thisLayer = this.layers[wmsIndex].split(",");
+ var thisScale = this.getScale();
+ var str_layer = "";
+ var cnt_layer = 0;
+ for (var i = 0; i < this.wms[wmsIndex].objLayer.length; i++) {
+ var currentLayer = this.wms[wmsIndex].objLayer[i];
+ var myLayername = currentLayer.layer_name;
+
+ var myMinscale = currentLayer.gui_layer_minscale;
+ var myMaxscale = currentLayer.gui_layer_maxscale;
+
+ for (var ii = 0; ii < thisLayer.length; ii++) {
+ if (thisLayer[ii] == myLayername && !currentLayer.has_childs) {
+ if (myMinscale !== 0 && thisScale < myMinscale) {
+ continue;
+ }
+ if (myMaxscale !== 0 && thisScale > myMaxscale) {
+ continue;
+ }
+ if (cnt_layer > 0) {
+ str_layer += ",";
+ }
+ str_layer += thisLayer[ii];
+ cnt_layer++;
+ }
+ }
+ }
+ var str_layerstyles = [];
+ str_layerstyles[0] = str_layer;
+ return str_layerstyles;
+
+ };
+
+ this.repaintScale = function(x, y, scale){
+ if (x === null && y === null) {
+ var arrayBBox = this.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) - (this.width / (mb_resolution * 100 * 2) * scale);
+ var miny = parseFloat(y) - (this.height / (mb_resolution * 100 * 2) * scale);
+ var maxx = parseFloat(x) + (this.width / (mb_resolution * 100 * 2) * scale);
+ var maxy = parseFloat(y) + (this.height / (mb_resolution * 100 * 2) * scale);
+ this.repaint(new Point(minx, miny), new Point(maxx, maxy));
+ };
+
+ this.repaint = function(min, max){
+ this.extent = min.x + "," + min.y + "," + max.x + "," + max.y;
+ this.setMapRequest();
+ };
+
+ this.setSingleMapRequest = function (wms_id) {
+ eventBeforeMapRequest.trigger({frameName:this.frameName});
+
+ var ts = mb_timestamp();
+
+ for (var ii = 0; ii < this.wms.length; ii++){
+ var currentWms = this.wms[ii];
+ if (currentWms.wms_id != wms_id) {
+ continue;
+ }
+ var newMapRequest = getLayerHtmlCode(ii);
+
+ if (mb_log) {
+ var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+ }
+ var myDivId = "div_" + ii;
+ writeTag(this.frameName, myDivId, newMapRequest);
+ var myMapId = "map_" + ii;
+ eventAfterMapRequest.trigger({"frameName":this.frameName, "myMapId":myMapId});
+ return true;
+ }
+ return false;
+
+ };
+
+ this.setMapRequest = function(){
+ var functionName = 'setMapRequest';
+
+ var ret = eventBeforeMapRequest.trigger({
+ frameName: this.frameName
+ }, "AND");
+ if (ret === false) {
+ return true;
+ }
+ var ts = mb_timestamp();
+ var myMapId = [];
+
+ var newMapRequest = "";
+
+ for (var ii = 0; ii < this.wms.length; ii++) {
+ var currentWms = this.wms[ii];
+
+ if (!(currentWms.gui_wms_visible > 0)) {
+ continue;
+ }
+ myMapId.push("map_" + ii);
+
+ newMapRequest += getLayerHtmlCode(ii);
+
+ }
+ writeTag(this.frameName, this.elementName+"_maps", newMapRequest);
+
+ eventAfterMapRequest.trigger({
+ "frameName": this.frameName,
+ "myMapId": myMapId.join(",")
+ });
+ };
+
+ var that = this;
+
+ var getLayerHtmlCode = function (ii) {
+ var currentWms = that.wms[ii];
+
+ var myDivId = "div_" + ii;
+ var myMapId = "map_" + ii;
+
+ //disable Layer which are out of scale
+ var validLayers = that.checkScale(ii);
+ var layerNames = validLayers.toString();
+
+ var newMapURL = false;
+ var opacityString = "";
+
+ if (that.layers[ii] !== "" && layerNames !== ''){
+ // get map URL
+ newMapURL = that.getMapUrl(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 = "";
+ if (newMapURL) {
+ imageString = "<img id='"+myMapId+"' name='mapimage' ";
+ imageString += "src='" + newMapURL + "' ";
+ imageString += "width='"+that.width+"' ";
+ imageString += "height='"+that.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>";
+
+ that.mapURL[ii]= newMapURL;
+ currentWms.mapURL = newMapURL;
+
+ if (mb_log && currentWms.mapURL) {
+ var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
+ }
+
+ return newMapRequest;
+ }
+
+ this.getWmsIdByTitle = function (title) {
+ for (var i=0; i < this.wms.length; i++) {
+ if (this.wms[i].wms_title == title) {
+ return this.wms[i].wms_id;
+ }
+ }
+ return null;
+ };
+
+ this.getWmsIndexById = function (wms_id) {
+ for (var i=0; i< this.wms.length; i++){
+ if(mb_mapObj[ind].wms[i].wms_id == wms_id){
+ return i;
+ }
+ }
+ return null;
+ };
+
+ this.removeWms = function (wmsIndex) {
+ 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 < this.wms.length; i++) {
+ if (i != wmsIndex) {
+ new_wmsarray.push(this.wms[i]);
+ new_layerarray.push(this.layers[i]);
+ new_querylayerarray.push(this.querylayers[i]);
+ new_stylesarray.push(this.styles[i]);
+ new_mapURLarray.push(this.mapURL[i]);
+ }
+ else {
+ wms_ID = this.wms[i].wms_id;
+ }
+ }
+ this.wms = new_wmsarray;
+ this.layers = new_layerarray;
+ this.querylayers = new_querylayerarray;
+ this.styles = new_stylesarray;
+ this.mapURL = new_mapURLarray;
+
+ var another_new_wmsarray = [];
+
+ for (i = 0; i < window.wms.length; i++) {
+ if (window.wms[i].wms_id != wms_ID) {
+ another_new_wmsarray.push(window.wms[i]);
+ }
+ }
+ window.wms = another_new_wmsarray;
+ };
+
+ /**
* move a wms or layer
*
* @param int wms_id id of wms to move
@@ -431,5 +843,6 @@
return new Point(clickX, clickY);
}
+
eventAfterMapObjectConstruction.trigger();
}
\ No newline at end of file
More information about the Mapbender_commits
mailing list