[Mapbender-commits] r3217 - branches/beck_dev_25/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Nov 11 08:50:02 EST 2008
Author: beck
Date: 2008-11-11 08:50:02 -0500 (Tue, 11 Nov 2008)
New Revision: 3217
Added:
branches/beck_dev_25/http/javascripts/mod_tooltip.php
branches/beck_dev_25/http/javascripts/old_tooltip24.php
branches/beck_dev_25/http/javascripts/old_tooltip_merged.php
branches/beck_dev_25/http/javascripts/wfsFilter.js
Log:
Added: branches/beck_dev_25/http/javascripts/mod_tooltip.php
===================================================================
--- branches/beck_dev_25/http/javascripts/mod_tooltip.php (rev 0)
+++ branches/beck_dev_25/http/javascripts/mod_tooltip.php 2008-11-11 13:50:02 UTC (rev 3217)
@@ -0,0 +1,360 @@
+<?php
+# $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
+# http://www.mapbender.org/index.php/mod_toggleModule.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+$wfs_conf_filename = "wfs_default.conf";
+include '../include/dyn_php.php';
+$fname = dirname(__FILE__) . "/../../conf/" . $wfs_conf_filename;
+if (file_exists($fname)) {
+ include($fname);
+}
+else {
+ $e = new mb_exception("tooltip.php: Configuration file " . $wfs_conf_filename . " not found.");
+}
+
+echo "var tooltipTarget ='".$e_target[0]."';";
+
+include '../include/dyn_js.php';
+?>
+//tolerance when we ask wfs
+var mb_wfs_tolerance = 8;
+
+//initialize Element Vars
+
+//destination frame for the request (creates Popup if empty)
+if(typeof(tooltip_destinationFrame)==='undefined')
+ var tooltip_destinationFrame = "";
+if(typeof(tooltip_timeDelay)==='undefined')
+ var tooltip_timeDelay = 1000;
+if(typeof(tooltip_styles)==='undefined')
+ var tooltip_styles = "";
+if(typeof(tooltip_width)==='undefined')
+ var tooltip_width = 270;
+if(typeof(tooltip_height)==='undefined')
+ var tooltip_height = 200;
+if(typeof(tooltip_styles_detail)==='undefined')
+ var tooltip_styles_detail = "";
+try{
+ var no_result_text = eval(tooltip_noResultArray);
+}catch(e){
+ var no_result_text = ["Kein Ergebnis.",'<body onLoad="javascript:window.close()">'];
+}
+var mouseMoves=0;
+var tooltipWin=null;
+var point;
+var tooltipWfsRequestCount = 0;
+var tooltipWmsRequestCount = 0;
+var numberOfFinishedWfsRequests = 0;
+var numberOfFinishedWmsRequests = 0;
+var visibleRequest = 0;
+var TooltipMsg = {'title':"<?php echo _mb("Information");?>"};
+
+//buttonWfs_toDigitize_on ="0";
+
+function mod_tooltipInit(){
+ $(window.frames[tooltipTarget].document).mousemove(function(event){
+ mb_getMousePos(event,tooltipTarget);
+ mod_tooltip_run();
+ }).mouseout(function(){mouseMoves=0;});
+}
+
+eventInit.register(mod_tooltipInit);
+
+function mod_tooltip_run(){
+ mouseMoves++;
+ setTimeout("if(mouseMoves=="+mouseMoves+"&&clickX=="+clickX+"&&clickY=="+clickY+")fireRequests();",tooltip_timeDelay);
+}
+
+function fireRequests(){
+ var ind = getMapObjIndexByName(tooltipTarget);
+ point = new Point(clickX,clickY);
+ var point_geom = new Geometry(geomType.point);
+ point_geom.addPoint(mapToReal(tooltipTarget,point));
+ visibleRequest = 0;
+
+ //FeatureInfo requests
+ urls = mb_mapObj[ind].getFeatureInfoRequests(point);
+ tooltipWmsRequestCount = urls.length;
+ numberOfFinishedWmsRequests = 0;
+ for(var j=0;j < urls.length;j++){
+ mb_ajax_post("../extensions/ext_featureInfoTunnel.php", {url:urls[j]},
+ checkFeatureInfoResults);
+ }
+
+ //WFS requests
+ requests = getWfsRequests(tooltipTarget, point_geom, true);
+ tooltipWfsRequestCount = requests.length;
+ numberOfFinishedWfsRequests = 0;
+ resultGeomArray = new GeometryArray();
+ for(var j=0;j< requests.length;j++){
+ mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,requests[j],function(js_code,status){
+ if (js_code) {
+ eval(js_code);
+ }
+ if (typeof(geom) == "undefined") {
+ var geom = new GeometryArray();
+ }
+ checkWfsResultsFinished(geom);
+ });
+ }
+}
+
+function checkFeatureInfoResults(js_code,status){
+ numberOfFinishedWmsRequests++;
+
+ //check if there are results
+ if(js_code == ""){
+ if(!isFirstResult())
+ displayResultDoc("");
+ return;
+ }
+
+ for(var k=0;k < no_result_text.length;k++){
+ if(js_code.indexOf(no_result_text[k])!==-1){
+ if(!isFirstResult())
+ displayResultDoc("");
+ return;
+ }
+ }
+
+ //output code
+ displayResultDoc(js_code);
+}
+
+function checkWfsResultsFinished(g){
+ //check if all wfs requests arrived
+ numberOfFinishedWfsRequests++;
+ if (typeof(g) == 'object'){
+ resultGeomArray.union(g);
+ }
+ if (numberOfFinishedWfsRequests == tooltipWfsRequestCount) {
+ if(resultGeomArray.count()>0){
+ //generate and output result
+ if(resultGeomArray.count()>1)
+ var html = createSimpleWfsResultHtml(resultGeomArray);
+ else
+ var html = createDetailedWfsResultHtml(resultGeomArray);
+ displayResultDoc(html);
+ }
+ else if(!isFirstResult())
+ displayResultDoc("");
+ }
+}
+
+function isFirstResult(){
+ return visibleRequest == 0;
+}
+
+function isLastResult(){
+ return (numberOfFinishedWfsRequests == tooltipWfsRequestCount && numberOfFinishedWmsRequests == tooltipWmsRequestCount);
+}
+
+function displayResultDoc(html){
+ //test if we have a fixed destination and create popup otherwise
+ if(tooltip_destinationFrame=="")
+ return showBalloonFrame(html);
+
+ //put the frame there
+ $("#"+tooltip_destinationFrame).each(function(){
+ var oDoc = this.contentWindow || this.contentDocument;
+ if (oDoc.document) {
+ oDoc = oDoc.document;
+ }
+ if(isFirstResult())
+ oDoc.open();
+ oDoc.write(html);
+ if(isLastResult())
+ oDoc.close();
+ });
+ visibleRequest++;
+}
+
+function showBalloonFrame(html){
+ if(isFirstResult()){
+ //claculate Position
+ x=point.x+parseInt(document.getElementById(tooltipTarget).style.left);
+ y=point.y+parseInt(document.getElementById(tooltipTarget).style.top);
+
+ //hide old Popup
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+
+ //create Popup and append document
+ tooltipWin = new mb_popup({html:'<iframe id="tooltipWin" name="tooltipWin" src="about:blank"/>',title:TooltipMsg.title,width:tooltip_width,height:tooltip_height,balloon:true,left:x,top:y});
+ //open document
+ tooltipWin.open();
+ }
+ tooltipWin.write(html);
+
+ if(isLastResult()){
+ tooltipWin.close();
+ }
+
+ //finally display popup
+ tooltipWin.show();
+}
+
+function getWfsRequests(target, geom, checkscale, filteroption){
+ //get all configurations
+ wfs_config = get_complete_wfs_conf();
+ var ind = getMapObjIndexByName(target);
+ var db_wfs_conf_id = [];
+ var js_wfs_conf_id = [];
+
+ //search configurations that are selected (and in scale)
+ for (var i=0; i < mb_mapObj[ind].wms.length; i++){
+ for(var ii=0; ii < mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ var o = mb_mapObj[ind].wms[i].objLayer[ii];
+ if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+ if(!checkscale || o.checkScale(mb_mapObj[ind]))
+ db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+ }
+ }
+ }
+ for(var i=0; i < db_wfs_conf_id.length; i++){
+ for(var ii=0; ii < wfs_config.length; ii++){
+ if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]){
+ js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+ break;
+ }
+ }
+ }
+
+ //build requests
+ var requests = [];
+
+ for(var i=0;i < js_wfs_conf_id.length; i++){
+ //build url
+ var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ url += mb_getConjunctionCharacter(wfs_config[js_wfs_conf_id[i]]['wfs_getfeature']);
+ url += "service=wfs&request=getFeature&version=1.0.0";
+ url += "&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name'];
+ url += "&filter=";
+
+ //search for geometry column
+ var geometryCol;
+ for(var j=0; j < wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
+ if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
+ geometryCol = wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+ }
+ }
+
+ //get filter
+ var filter = new WfsFilter();
+ filter.addSpatial(geom, geometryCol, filteroption, wfs_config[js_wfs_conf_id[i]]['featuretype_srs'], target);
+
+ requests.push({'url':url,'filter':filter.toString(), 'typename':wfs_config[js_wfs_conf_id[i]]['featuretype_name'],'js_wfs_conf_id':js_wfs_conf_id[i], 'db_wfs_conf_id':db_wfs_conf_id[i]});
+ }
+
+ return requests;
+}
+
+function createSimpleWfsResultHtml(_geomArray){
+ var geometryIndex = 0;
+ wfsConf = get_complete_wfs_conf();
+ var html = '<html><head><style type="text/css">';
+ html += tooltip_styles;
+ html += "</style></head><body><table>\n";
+
+ for (var i = 0 ; i < _geomArray.count(); i ++) {
+ if (_geomArray.get(i).get(-1).isComplete()) {
+ html += "\t<tr class='list_"+(i%2?"uneven":"even")+"'>\n\t\t<td \n";
+// html += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+// html += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+// html += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+ var geomName = getWfsListEntry(_geomArray.get(i));
+ html += ">" + geomName +"</td>";
+ html += "\t\t</tr>\n";
+ }
+ }
+
+ html += "</table></body>\n";
+ return html;
+}
+
+function createDetailedWfsResultHtml(_geomArray){
+ var geometryIndex = 0;
+ var cnt = 0;
+ wfsConf = get_complete_wfs_conf();
+ var html = '<html><head><style type="text/css">';
+ html += tooltip_styles_detail;
+ html += "</style></head><body><table>\n";
+
+ var wfsConfIndex = _geomArray.get(geometryIndex).wfs_conf;
+ var currentWfsConf = wfsConf[wfsConfIndex];
+ for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
+ if(currentWfsConf.element[i].f_show_detail==1){
+ if( _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
+ html +="<tr class='list_"+(cnt%2?"uneven":"even")+"'><td>\n";
+ html += currentWfsConf.element[i].f_label;
+ html +="</td>\n";
+ html += "<td>\n";
+ var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name);
+ if(currentWfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+ var setUrl = currentWfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+elementVal+"' target='_blank'");
+ if(setUrl.match(/><\/a>/)){
+ var newLink = setUrl.replace(/><\/a>/, ">"+elementVal+"</a>");
+ }
+ else{
+ var newLink = setUrl;
+ }
+ html += newLink;
+ }
+ else{
+ html += elementVal;
+ }
+ html += "</td></tr>\n";
+ cnt++;
+ }
+ }
+ }
+
+ html += "</table></body>\n";
+ return html;
+}
+
+
+function getWfsListEntry (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+ if (typeof(wfsConfId) == "number" && wfsConfId >=0 && wfsConfId < wfsConf.length) {
+ var resultArray = [];
+ for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
+ if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1 && geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) !=false) {
+ var pos = wfsConf[wfsConfId]['element'][i]['f_respos'];
+ if (typeof(resultArray[pos]) != "undefined") {
+ resultArray[pos] += " " + geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ else {
+ resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ }
+ }
+ var resultName = resultArray.join(" ");
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else {
+ return false;
+ }
+}
+
Added: branches/beck_dev_25/http/javascripts/old_tooltip24.php
===================================================================
--- branches/beck_dev_25/http/javascripts/old_tooltip24.php (rev 0)
+++ branches/beck_dev_25/http/javascripts/old_tooltip24.php 2008-11-11 13:50:02 UTC (rev 3217)
@@ -0,0 +1,278 @@
+<?php
+# $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
+# http://www.mapbender.org/index.php/mod_toggleModule.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+$wfs_conf_filename = "wfs_default.conf";
+include '../include/dyn_php.php';
+$fname = dirname(__FILE__) . "/../../conf/" . $wfs_conf_filename;
+if (file_exists($fname)) {
+ include($fname);
+}
+else {
+ $e = new mb_exception("tooltip.php: Configuration file " . $wfs_conf_filename . " not found.");
+}
+
+echo "var tooltipTarget ='".$e_target[0]."';";
+
+include '../include/dyn_js.php';
+?>
+
+var mb_wfs_tolerance = 20;
+var tooltipTime = 500;
+
+var mouseMoves=0;
+var tooltipWin=null;
+var point;
+var numberOfFinishedAjaxCalls = 0;
+buttonWfs_toDigitize_on ="0";
+
+function mod_tooltipInit(){
+ $(window.frames["mapframe1"].document).mousemove(function(event){
+ mod_tooltip_run();
+ mb_getMousePos(event,"mapframe1");
+ }).mouseout(function(){mouseMoves=0;});
+}
+
+mb_registerInitFunctions("mod_tooltipInit();");
+
+function mod_tooltip_run(){
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ mouseMoves++;
+ setTimeout("if(mouseMoves=="+mouseMoves+")requestWfs();",tooltipTime);
+}
+
+function showWMSBalloon(){
+ x=clickX+parseInt(document.getElementById("mapframe1").style.left);
+ y=clickY+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ var ind = getMapObjIndexByName("mapframe1");
+ req = mb_mapObj[ind].getFeatureInfoRequests({x:clickX,y:clickY});
+ if(req)
+ tooltipWin = new mb_popup({url:req[0],title:"Feature Info",width:270,height:200,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function showWFSBalloon(geom){
+ x=point.x+parseInt(document.getElementById("mapframe1").style.left);
+ y=point.y+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWin&&tooltipWin.isVisible())
+ tooltipWin.destroy();
+ tooltipWin = new mb_popup({title:searchPopupTitle,html:createListOfGeometries(),width:270,height:150,balloon:true,left:x,top:y});
+ tooltipWin.show();
+}
+
+function requestWfs(){
+ point = new Point(clickX, clickY);
+
+ var ind = getMapObjIndexByName("mapframe1");
+ var db_wfs_conf_id = [];
+ js_wfs_conf_id = [];
+ _geomArray = new GeometryArray();
+
+ wfs_config = window.frames["wfs_conf"].get_wfs_conf();
+ for (var i=0; i<mb_mapObj[ind].wms.length; i++){
+ str_LayerStyles=mb_checkScale("mapframe1",ind,i);
+ arr_layers = str_LayerStyles[0].split(",");
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ var o = mb_mapObj[ind].wms[i].objLayer[ii];
+ if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+ for(iii=0;iii<arr_layers.length;iii++){
+ if(o.layer_name == arr_layers[iii]){
+ db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+ break;
+ }
+ }
+ }
+ }
+ }
+ for(var i=0; i<db_wfs_conf_id.length; i++){
+ for(var ii=0; ii<wfs_config.length; ii++){
+ if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]) js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+ }
+ }
+
+ numberOfAjaxCalls_ = js_wfs_conf_id.length;
+
+
+
+ var buffer = mb_wfs_tolerance/2;
+ var mapPosXAddPix = clickX + buffer;
+ var mapPosYAddPix = clickY + buffer;
+ var mapPosXRemovePix = clickX - buffer;
+ var mapPosYRemovePix = clickY - buffer;
+ var realWorld1 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+ var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+ for(var i=0; i<js_wfs_conf_id.length; i++){
+ var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ param = "service=wfs&request=getFeature&version=1.0.0&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name']+"&filter=";
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+ filter += "<Intersects><ogc:PropertyName>";
+ for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
+ if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
+ filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+ }
+ }
+ filter += "</ogc:PropertyName><gml:Polygon srsName='4326'><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ filter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></ogc:Filter>";
+ url += param;
+ mb_get_geom_(url, filter, i, wfs_config[js_wfs_conf_id[i]]['featuretype_name'], js_wfs_conf_id[i], db_wfs_conf_id[i]);
+ }
+ return true;
+}
+function mb_get_geom_(url, filter, index, typename, js_wfs_conf_id, db_wfs_conf_id) {
+
+ mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,{'url':url,'filter':filter,'typename':typename,'js_wfs_conf_id':js_wfs_conf_id, 'db_wfs_conf_id':db_wfs_conf_id},function(js_code,status){
+ if (js_code) {
+ eval(js_code);
+ }
+ if (typeof(geom) == "undefined") {
+ var geom = new GeometryArray();
+ }
+ checkIfAllAjaxCallsFinished_(geom);
+ });
+}
+
+function checkIfAllAjaxCallsFinished_ (geom) {
+ numberOfFinishedAjaxCalls++;
+ if (typeof(geom) == 'object'){
+ _geomArray.union(geom);
+ }
+ if (numberOfFinishedAjaxCalls == numberOfAjaxCalls_) {
+ numberOfFinishedAjaxCalls = 0;
+ if(_geomArray.count()>0)
+ showWFSBalloon(_geomArray);
+ }
+}
+
+function createListOfGeometries(){
+ if(_geomArray.count()>0){
+ var listOfGeom = "<table style='background-color:#EEEEEE;'>\n";
+ if (_geomArray.count() > 0) {
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<tr><td style='color:black;font-size:12px;'>edit all</td>\n";
+ listOfGeom += "<td><img title='edit all' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryArrayToDigitize(_geomArray);'></img>";
+ listOfGeom += "</td>\n</tr>\n";
+ listOfGeom += "<tr>\n<td> </td>\n</tr>\n";
+ }
+ for (var i = 0 ; i < _geomArray.count(); i ++) {
+ if (_geomArray.get(i).get(-1).isComplete()) {
+ listOfGeom += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
+ listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+ listOfGeom += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+ listOfGeom += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+ var geomName = getListTitle(_geomArray.get(i));
+ //if (_geomArray.get(i).geomType == geomType.polygon) {geomName += "(polygon)";}
+ //else if (_geomArray.get(i).geomType == geomType.line) {geomName += "(line)";}
+ //else if (_geomArray.get(i).geomType == geomType.point) {geomName += "(point)";}
+ listOfGeom += ">" + geomName +"</td>";
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<td><img title='edit geometry object' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryToDigitize("+i+");'></img></td>";
+ }
+ listOfGeom += "\t\t</tr>\n";
+ }
+ }
+ }
+ listOfGeom += "</table>\n";
+ return listOfGeom;
+ }
+ else{
+ geometryIndex = 0;
+ wfsConf = get_complete_wfs_conf();
+ var wfsConfIndex = _geomArray.get(0).wfs_conf;
+ var currentWfsConf = wfsConf[wfsConfIndex];
+
+ var resultHtml = "";
+ resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+ for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
+ if(currentWfsConf.element[i].f_show_detail==1){
+ if( _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
+ //console.log(currentWfsConf.element[i].element_name+"---"+currentWfsConf.element[i].f_respos);
+ resultHtml +="<tr><td>\n";
+ resultHtml += currentWfsConf.element[i].f_label;
+ resultHtml +="</td>\n";
+ resultHtml += "<td>\n";
+ var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name);
+ if(currentWfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+ var setUrl = currentWfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+elementVal+"' target='_blank'");
+ if(setUrl.match(/><\/a>/)){
+ var newLink = setUrl.replace(/><\/a>/, ">"+elementVal+"</a>");
+ }
+ else{
+ var newLink = setUrl;
+ }
+ if(openLinkFromSearch=='1'){
+ window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
+ }
+ resultHtml += newLink;
+ }
+ else{
+ resultHtml += elementVal;
+ }
+ resultHtml += "</td></tr>\n";
+ }
+ }
+ }
+ resultHtml += "</table>\n";
+ return resultHtml;
+ }
+}
+
+function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
+ return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
+}
+
+function Numsort (a, b) {
+ return a - b;
+}
+
+function getListTitle (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+ if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
+ var resultArray = [];
+ var resultName = "";
+ for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
+ if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1 && geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) !=false) {
+ var pos = wfsConf[wfsConfId]['element'][i]['f_respos'];
+ if (typeof(resultArray[pos]) != "undefined") {
+ resultArray[pos] += " " + geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ else {
+ resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
+ }
+ }
+ resultArray.sort(Numsort);
+ var resultName = resultArray.join(" ");
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else {
+ return msgObj.digitizeDefaultGeometryName;
+ }
+}
Added: branches/beck_dev_25/http/javascripts/old_tooltip_merged.php
===================================================================
--- branches/beck_dev_25/http/javascripts/old_tooltip_merged.php (rev 0)
+++ branches/beck_dev_25/http/javascripts/old_tooltip_merged.php 2008-11-11 13:50:02 UTC (rev 3217)
@@ -0,0 +1,338 @@
+<?php
+# $Id: mod_toggleModule.php 2238 2008-03-13 14:24:56Z christoph $
+# http://www.mapbender.org/index.php/mod_toggleModule.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validatePermission.php");
+$wfs_conf_filename = "wfs_default.conf";
+include '../include/dyn_php.php';
+$fname = dirname(__FILE__) . "/../../conf/" . $wfs_conf_filename;
+if (file_exists($fname)) {
+ include($fname);
+}
+else {
+ $e = new mb_exception("tooltip.php: Configuration file " . $wfs_conf_filename . " not found.");
+}
+
+echo "var tooltipTarget ='".$e_target[0]."';";
+
+include '../include/dyn_js.php';
+?>
+
+var mb_wfs_tolerance = 20;
+var tooltipTime = 500;
+var no_result_text ="Kein Ergebnis.";
+
+var mouseMoves=0;
+var tooltipWFSWin=null;
+var tooltipWMSWin=null;
+var point;
+var numberOfFinishedAjaxCalls = 0;
+buttonWfs_toDigitize_on ="0";
+
+function mod_tooltipInit(){
+ $(window.frames["mapframe1"].document).mousemove(function(event){
+ mod_tooltip_run();
+ mb_getMousePos(event,"mapframe1");
+ }).mouseout(function(){mouseMoves=0;});
+}
+
+mb_registerInitFunctions("mod_tooltipInit();");
+
+function mod_tooltip_run(){
+ if(tooltipWFSWin && tooltipWFSWin.isVisible())
+ tooltipWFSWin.destroy();
+ if(tooltipWMSWin && tooltipWMSWin.isVisible())
+ tooltipWMSWin.destroy();
+ mouseMoves++;
+ setTimeout("if(mouseMoves=="+mouseMoves+")requestWfs();",tooltipTime);
+ setTimeout("if(mouseMoves=="+mouseMoves+")showWMSBalloon();",tooltipTime);
+}
+
+function showWMSBalloon(){
+ if(mb_getScale('mapframe1') > tooltipMinScale) {
+ return;
+ }
+
+ x=clickX+parseInt(document.getElementById("mapframe1").style.left);
+ y=clickY+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWMSWin && tooltipWMSWin.isVisible())
+ tooltipWMSWin.destroy();
+ url = getfirstFeatureInfoRequest("mapframe1",clickX,clickY);
+
+ mb_ajax_post("../extensions/ext_featureInfoTunnel.php?url="+escape(url), null, function(js_code,status){
+ if(js_code.indexOf(no_result_text)!==-1)
+ return;
+ tooltipWMSWin = new mb_popup({html:'<iframe id="tooltipWMSWin" name="tooltipWMSWin" src="about:blank"/>',title:"Feature Info",width:270,height:200,balloon:true,left:x,top:y});
+ $("#"+tooltipWMSWin.id+" iframe").each(function(){
+ var oDoc = this.contentWindow || this.contentDocument;
+ if (oDoc.document) {
+ oDoc = oDoc.document;
+ }
+ oDoc.write(js_code);
+ });
+ tooltipWMSWin.show();
+ });
+}
+
+function showWFSBalloon(geom){
+ if(mb_getScale('mapframe1') > tooltipMinScale) {
+ return;
+ }
+ x=point.x+parseInt(document.getElementById("mapframe1").style.left);
+ y=point.y+parseInt(document.getElementById("mapframe1").style.top);
+ if(tooltipWFSWin && tooltipWFSWin.isVisible())
+ tooltipWFSWin.destroy();
+ tooltipWFSWin = new mb_popup({title:searchPopupTitle,html:createListOfGeometries(),width:270,height:150,balloon:true,left:x-270,top:y-150});
+ tooltipWFSWin.show();
+}
+
+function requestWfs(){
+ point = new Point(clickX, clickY);
+
+ var ind = getMapObjIndexByName("mapframe1");
+ var db_wfs_conf_id = [];
+ js_wfs_conf_id = [];
+ _geomArray = new GeometryArray();
+
+ wfs_config = window.frames["wfs_conf"].get_wfs_conf();
+ for (var i=0; i<mb_mapObj[ind].wms.length; i++){
+ for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+ var o = mb_mapObj[ind].wms[i].objLayer[ii];
+ if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+ if(o.checkScale(mb_mapObj[ind]))
+ db_wfs_conf_id[db_wfs_conf_id.length] = o.gui_layer_wfs_featuretype;
+ }
+ }
+ }
+ for(var i=0; i<db_wfs_conf_id.length; i++){
+ for(var ii=0; ii<wfs_config.length; ii++){
+ if(wfs_config[ii]['wfs_conf_id'] == db_wfs_conf_id[i]) js_wfs_conf_id[js_wfs_conf_id.length] = ii;
+ }
+ }
+
+ numberOfAjaxCalls_ = js_wfs_conf_id.length;
+
+ var buffer = mb_wfs_tolerance/2;
+ var mapPosXAddPix = clickX + buffer;
+ var mapPosYAddPix = clickY + buffer;
+ var mapPosXRemovePix = clickX - buffer;
+ var mapPosYRemovePix = clickY - buffer;
+ var realWorld1 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+ var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+ var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+ for(var i=0; i<js_wfs_conf_id.length; i++){
+ var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ param = "service=wfs&request=getFeature&version=1.0.0&typename="+ wfs_config[js_wfs_conf_id[i]]['featuretype_name']+"&filter=";
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>";
+ filter += "<Intersects><ogc:PropertyName>";
+ for(var j=0; j<wfs_config[js_wfs_conf_id[i]]['element'].length; j++){
+ if(wfs_config[js_wfs_conf_id[i]]['element'][j]['f_geom'] == 1){
+ filter += wfs_config[js_wfs_conf_id[i]]['element'][j]['element_name'];
+ }
+ }
+ filter += "</ogc:PropertyName><gml:Polygon srsName='4326'><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ filter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects></ogc:Filter>";
+ url += param;
+ mb_get_geom_(url, filter, i, wfs_config[js_wfs_conf_id[i]]['featuretype_name'], js_wfs_conf_id[i], db_wfs_conf_id[i]);
+ }
+ return true;
+}
+function mb_get_geom_(url, filter, index, typename, js_wfs_conf_id, db_wfs_conf_id) {
+
+ mb_ajax_post("../" + wfsResultModulePath + wfsResultModuleFilename,{'url':url,'filter':filter,'typename':typename,'js_wfs_conf_id':js_wfs_conf_id, 'db_wfs_conf_id':db_wfs_conf_id},function(js_code,status){
+ if (js_code) {
+ eval(js_code);
+ }
+ if (typeof(geom) == "undefined") {
+ var geom = new GeometryArray();
+ }
+ checkIfAllAjaxCallsFinished_(geom);
+ });
+}
+
+function checkIfAllAjaxCallsFinished_ (geom) {
+ numberOfFinishedAjaxCalls++;
+ if (typeof(geom) == 'object'){
+ _geomArray.union(geom);
+ }
+ if (numberOfFinishedAjaxCalls == numberOfAjaxCalls_) {
+ numberOfFinishedAjaxCalls = 0;
+ if(_geomArray.count()>0)
+ showWFSBalloon(_geomArray);
+ }
+}
+
+function createListOfGeometries(){
+ if(_geomArray.count()>0){
+ var listOfGeom = "<table style='background-color:#EEEEEE;'>\n";
+ if (_geomArray.count() > 0) {
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<tr><td style='color:black;font-size:12px;'>edit all</td>\n";
+ listOfGeom += "<td><img title='edit all' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryArrayToDigitize(_geomArray);'></img>";
+ listOfGeom += "</td>\n</tr>\n";
+ listOfGeom += "<tr>\n<td> </td>\n</tr>\n";
+ }
+ for (var i = 0 ; i < _geomArray.count(); i ++) {
+ if (_geomArray.get(i).get(-1).isComplete()) {
+ listOfGeom += "\t<tr>\n\t\t<td style = 'color:blue;font-size:12px;cursor:pointer;'\n";
+ listOfGeom += "\t\t\t onmouseover='mb_wfs_perform(\"over\",_geomArray.get("+i+"));' ";
+ listOfGeom += " onmouseout='mb_wfs_perform(\"out\",_geomArray.get("+i+"))' ";
+ listOfGeom += " onclick='mb_wfs_perform(\"click\",_geomArray.get("+i+"));' ";
+ var geomName = getListTitle(_geomArray.get(i));
+ listOfGeom += ">" + geomName +"</td>";
+ if(buttonWfs_toDigitize_on==1){
+ listOfGeom += "<td><img title='edit geometry object' src='"+buttonWfs_toDigitize_src+"' style='cursor:pointer' onclick='appendGeometryToDigitize("+i+");'></img></td>";
+ }
+ listOfGeom += "\t\t</tr>\n";
+ }
+ }
+ }
+ listOfGeom += "</table>\n";
+ return listOfGeom;
+ }
+ else{
+ geometryIndex = 0;
+ wfsConf = get_complete_wfs_conf();
+ var wfsConfIndex = _geomArray.get(0).wfs_conf;
+ var currentWfsConf = wfsConf[wfsConfIndex];
+
+ var resultHtml = "";
+ resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+ for (var i = 0 ; i <currentWfsConf.element.length; i ++) {
+ if(currentWfsConf.element[i].f_show_detail==1){
+ if( _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name)!=false){
+ //console.log(currentWfsConf.element[i].element_name+"---"+currentWfsConf.element[i].f_respos);
+ resultHtml +="<tr><td>\n";
+ resultHtml += currentWfsConf.element[i].f_label;
+ resultHtml +="</td>\n";
+ resultHtml += "<td>\n";
+ var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name);
+ if(currentWfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+ var setUrl = currentWfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='"+elementVal+"' target='_blank'");
+ if(setUrl.match(/><\/a>/)){
+ var newLink = setUrl.replace(/><\/a>/, ">"+elementVal+"</a>");
+ }
+ else{
+ var newLink = setUrl;
+ }
+ if(openLinkFromSearch=='1'){
+ window.open(elementVal, elementVal,"width=500, height=400,left=100,top=100,scrollbars=yes");
+ }
+ resultHtml += newLink;
+ }
+ else{
+ resultHtml += elementVal;
+ }
+ resultHtml += "</td></tr>\n";
+ }
+ }
+ }
+ resultHtml += "</table>\n";
+ return resultHtml;
+ }
+}
+
+function isValidWfsConfIndex (wfsConf, wfsConfIndex) {
+ return (typeof(wfsConfIndex) == "number" && wfsConfIndex >=0 && wfsConfIndex < wfsConf.length);
+}
+
+function Numsort (a, b) {
+ return a - b;
+}
+
+function getListTitle (geom) {
+ wfsConfId = geom.wfs_conf;
+ wfsConf = window.frames["wfs_conf"].get_wfs_conf();
+ if (isValidWfsConfIndex(wfsConf, wfsConfId)) {
+ var resultArray = [];
+ var resultName = "";
+ for (var i = 0 ; i < wfsConf[wfsConfId]['element'].length ; i++) {
+ if (wfsConf[wfsConfId]['element'][i]['f_show'] == 1 && geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) !=false) {
+ var pos = wfsConf[wfsConfId]['element'][i]['f_respos'];
+ if (typeof(resultArray[pos]) != "undefined") {
+ resultArray[pos] += " " + geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ else {
+ resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
+ }
+ resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
+ }
+ }
+ resultArray.sort(Numsort);
+ var resultName = resultArray.join(" ");
+ if (resultName == "") {
+ resultName = wfsConf[wfsConfId]['g_label'];
+ }
+ return resultName;
+ }
+ else {
+ return msgObj.digitizeDefaultGeometryName;
+ }
+}
+
+function getfirstFeatureInfoRequest(fName,x,y,path) {
+ 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(validation){
+ newfeatureInfoRequest += requestParams;
+ return newfeatureInfoRequest;
+ }
+ }
+ }
+ }
+ return false;
+}
Added: branches/beck_dev_25/http/javascripts/wfsFilter.js
===================================================================
--- branches/beck_dev_25/http/javascripts/wfsFilter.js (rev 0)
+++ branches/beck_dev_25/http/javascripts/wfsFilter.js 2008-11-11 13:50:02 UTC (rev 3217)
@@ -0,0 +1,236 @@
+function WfsFilter () {
+
+ this.operators = [
+ {
+ "operator":"==",
+ "wfsOpenTag":"PropertyIsEqualTo",
+ "wfsCloseTag":"PropertyIsEqualTo"
+ },
+ {
+ "operator":">=",
+ "wfsOpenTag":"PropertyIsGreaterThanOrEqualTo",
+ "wfsCloseTag":"PropertyIsGreaterThanOrEqualTo"
+ },
+ {
+ "operator":"<=",
+ "wfsOpenTag":"PropertyIsLessThanOrEqualTo",
+ "wfsCloseTag":"PropertyIsLessThanOrEqualTo"
+ },
+ {
+ "operator":">>",
+ "wfsOpenTag":"PropertyIsGreaterThan",
+ "wfsCloseTag":"PropertyIsGreaterThan"
+ },
+ {
+ "operator":"<<",
+ "wfsOpenTag":"PropertyIsLessThan",
+ "wfsCloseTag":"PropertyIsLessThan"
+ },
+ {
+ "operator":"<>",
+ "wfsOpenTag":"PropertyIsNotEqualTo",
+ "wfsCloseTag":"PropertyIsNotEqualTo"
+ },
+ {
+ "operator":"LIKE",
+ "wfsOpenTag":"PropertyIsLike wildCard='*' singleChar='.' escape='!'",
+ "wfsCloseTag":"PropertyIsLike"
+ }
+ ];
+
+ var conditionToString = function (condition, operator){
+ var splitParam = condition.split(operator);
+ var columnName = trim(splitParam[0]);
+ var columnValue = trim(splitParam[1]);
+
+/*
+ if (operator == 'LIKE') {
+ columnValue = "*"+ columnValue +"*";
+ }
+*/
+ for (var i = 0 ; i < that.operators.length ; i++) {
+ if (that.operators[i].operator == operator){
+
+ // add condition: Property
+ var condString = '<'+that.operators[i].wfsOpenTag+'>' +
+ '<PropertyName>'+columnName+'</PropertyName>' +
+ '<Literal>'+columnValue+'</Literal>' +
+ '</'+that.operators[i].wfsCloseTag+'>';
+
+/*
+ // add condition: Property is not null
+ '<ogc:Not><ogc:PropertyIsNull>' +
+ '<ogc:PropertyName>'+columnName+'</ogc:PropertyName>' +
+ '</ogc:PropertyIsNull></ogc:Not>';
+*/
+ return condString;
+ }
+ }
+ return "";
+ };
+
+ var getOperatorFromCondition = function (aCondition) {
+ for (var j = 0; j < that.operators.length; j++) {
+ if (aCondition.match(that.operators[j].operator)) {
+ return that.operators[j].operator;
+ }
+ }
+ return false;
+ };
+
+ /**
+ * parse the filter from the HTML form,
+ *
+ * @param {String} filter like "[usertype]<>3 AND [firstname]==Emil"
+ */
+ this.parse = function (filter) {
+ if (filter !== '') {
+
+ filter = filter.replace(/\[/g,"");
+ filter = filter.replace(/\]/g,"");
+ var condArray = filter.split(' AND ');
+ var wfsCond = [];
+ for (var i = 0 ; i < condArray.length ; i++) {
+ var currentOperator = getOperatorFromCondition(condArray[i]);
+ if (!currentOperator) {
+ return false;
+ }
+ wfsCond.push(conditionToString(condArray[i], currentOperator));
+ }
+ conditionArray = conditionArray.concat(wfsCond);
+ }
+ return true;
+ };
+
+ this.addSpatial = function (spatialRequestGeom, geometryColumn, filteroption, srs, target) {
+ if(typeof(spatialRequestGeom) != "undefined"){
+ var spatialRequestFilter = "";
+ if(spatialRequestGeom.geomType == geomType.polygon){
+ spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
+ geometryColumn + "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">" +
+ "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ for(var k=0; k<spatialRequestGeom.count(); k++){
+ if (k > 0) {
+ spatialRequestFilter += " ";
+ }
+ spatialRequestFilter += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+ }
+ spatialRequestFilter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ spatialRequestFilter += "</gml:Polygon></" + filteroption + ">";
+ }
+ else if(spatialRequestGeom.geomType == geomType.line){
+ var rectangle = [];
+ rectangle = spatialRequestGeom.getBBox();
+
+ spatialRequestFilter += "<" + filteroption + "><ogc:PropertyName>" +
+ geometryColumn + "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">" +
+ "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>" +
+ rectangle[0].x+","+rectangle[0].y + " " +
+ rectangle[0].x+","+rectangle[1].y + " " +
+ rectangle[1].x+","+rectangle[1].y + " " +
+ rectangle[1].x+","+rectangle[0].y + " " +
+ rectangle[0].x+","+rectangle[0].y +
+ "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>" +
+ "</gml:Polygon></" + filteroption + ">";
+ }
+ else if(spatialRequestGeom.geomType == geomType.point){
+ var tmp = spatialRequestGeom.get(0);
+ var mapPos = makeRealWorld2mapPos(target,tmp.x, tmp.y);
+ var buffer = mb_wfs_tolerance/2;
+ var realWorld1 = makeClickPos2RealWorldPos(target,mapPos[0]-buffer,mapPos[1]-buffer);
+ var realWorld2 = makeClickPos2RealWorldPos(target,mapPos[0]+buffer,mapPos[1]-buffer);
+ var realWorld3 = makeClickPos2RealWorldPos(target,mapPos[0]+buffer,mapPos[1]+buffer);
+ var realWorld4 = makeClickPos2RealWorldPos(target,mapPos[0]-buffer,mapPos[1]+buffer);
+ spatialRequestFilter += "<Intersects><ogc:PropertyName>";
+ spatialRequestFilter += geometryColumn;
+ spatialRequestFilter += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ spatialRequestFilter += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ spatialRequestFilter += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ spatialRequestFilter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
+ }
+/*
+ spatialRequestFilter += "<ogc:Not><ogc:PropertyIsNull>";
+ spatialRequestFilter += "<ogc:PropertyName>" + geometryColumn + "</ogc:PropertyName>";
+ spatialRequestFilter += "</ogc:PropertyIsNull></ogc:Not>";
+*/
+ conditionArray.push(spatialRequestFilter);
+ }
+ };
+
+ this.addPreConfigured = function (propName, propValueArray, toUpper, operator) {
+ var orConditions = "";
+ for (var j=0; j < propValueArray.length; j++) {
+ if (operator == 'greater_than' || operator == 'less_than' || operator == 'equal') {
+ if(propValueArray[j]!=''){
+ var tag;
+ if (operator == 'greater_than') {
+ tag = "PropertyIsGreaterThan";
+ }
+ else if (operator == 'less_than') {
+ tag = "PropertyIsLessThan";
+ }
+ else if (operator == 'equal') {
+ tag = "PropertyIsEqualTo";
+ }
+
+ orConditions += "<ogc:" + tag + ">";
+ orConditions += "<ogc:PropertyName>" + propName + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>";
+
+ if (toUpper == 1) {
+ propValueArray[j] = propValueArray[j].toUpperCase();
+ }
+
+ orConditions += propValueArray[j] + "</ogc:Literal></ogc:" + tag + ">";
+ }
+ }
+ else {
+ var leftSide = "";
+ var rightSide = "*";
+
+ if (operator != 'rightside') {
+ leftSide = "*";
+ }
+ orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+ orConditions += "<ogc:PropertyName>" + propName + "</ogc:PropertyName>";
+ orConditions += "<ogc:Literal>" + leftSide;
+ if (toUpper == 1){
+ propValueArray[j] = propValueArray[j].toUpperCase();
+ }
+ orConditions += propValueArray[j] + rightSide;
+ orConditions += "</ogc:Literal></ogc:PropertyIsLike>";
+ }
+/*
+ orConditions += "<ogc:Not><ogc:PropertyIsNull>";
+ orConditions += "<ogc:PropertyName>" + propName + "</ogc:PropertyName>";
+ orConditions += "</ogc:PropertyIsNull></ogc:Not>";
+*/
+ }
+ if(propValueArray.length > 1){
+ orConditions = "<Or>" + orConditions + "</Or>";
+ }
+ this.add(orConditions);
+ };
+
+ this.add = function (aFilterString) {
+ conditionArray.push(aFilterString);
+ };
+
+ this.toString = function () {
+ var str = "";
+ str += "<ogc:Filter xmlns:ogc='http://www.opengis.net/ogc' ";
+ str += "xmlns:gml='http://www.opengis.net/gml'>";
+ if (conditionArray.length > 1) {
+ str += "<And>" + conditionArray.join("") + "</And>";
+ }
+ else {
+ str += conditionArray.join("");
+ }
+ str += "</ogc:Filter>";
+ return str;
+ };
+
+ var conditionArray = [];
+ var that = this;
+}
+
More information about the Mapbender_commits
mailing list