[Mapbender-commits] r2454 - branches/2.5/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu May 15 14:03:07 EDT 2008
Author: astrid_emde
Date: 2008-05-15 14:03:07 -0400 (Thu, 15 May 2008)
New Revision: 2454
Modified:
branches/2.5/http/javascripts/mod_wfs_SpatialRequest.php
Log:
added function mb_getConjunctionCharacter(..) to construct the getFeature-Request to check wether the request is well-formed (&,?)
Modified: branches/2.5/http/javascripts/mod_wfs_SpatialRequest.php
===================================================================
--- branches/2.5/http/javascripts/mod_wfs_SpatialRequest.php 2008-05-15 09:06:04 UTC (rev 2453)
+++ branches/2.5/http/javascripts/mod_wfs_SpatialRequest.php 2008-05-15 18:03:07 UTC (rev 2454)
@@ -1,7 +1,7 @@
<?php
#$Id$
#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_wfs_spatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
-# Copyright (C) 2002 CCGIS
+# 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
@@ -118,9 +118,9 @@
function wfsInitFunction (j) {
var functionCall = "mb_regButton_frame('initWfsButton', null, "+j+")";
- var x = new Function ("", functionCall);
+ var x = new Function ("", functionCall);
x();
-}
+}
function displayButtons() {
for (var i = 0 ; i < buttonWfs_id.length ; i ++) {
@@ -131,14 +131,14 @@
currentDiv.style.left = buttonWfs_x[i]
currentDiv.style.top = buttonWfs_y[i];
currentDiv.style.zIndex = buttonWfs_zIndex;
-
+
var currentImg = document.createElement("img");
currentImg.id = buttonWfs_id[i];
currentImg.name = buttonWfs_id[i];
currentImg.title = buttonWfs_title_off[i];
currentImg.src = buttonWfs_imgdir+buttonWfs_src[i];
currentImg.onmouseover = new Function("wfsInitFunction("+i+")");
-
+
currentDiv.appendChild(currentImg);
document.getElementsByTagName('body')[0].appendChild(currentDiv);
}
@@ -161,7 +161,7 @@
mod_wfs_spatialRequest_epsg = mb_mapObj[ind].epsg;
mb_registerSubFunctions("drawDashedLineExt()");
mb_registerPanSubElement("measuring");
-}
+}
function wfsEnable(obj) {
var el = window.frames[mod_wfs_spatialRequest_target].document;
@@ -169,14 +169,14 @@
el.onmousedown = null;
el.onmouseup = null;
el.onmousemove = null;
-
+
if (obj.id == button_point) {
if (activeButton == null) {
activeButton = obj;
}
mod_wfs_spatialRequest_geometry = new Geometry(geomType.point);
wfsAreaType_current = wfsAreaType_point;
- mod_wfs_spatialRequest_digitize_go(geomType.point);
+ mod_wfs_spatialRequest_digitize_go(geomType.point);
}
if (obj.id == button_polygon) {
if (activeButton == null) {
@@ -184,11 +184,11 @@
}
mod_wfs_spatialRequest_geometry = new Geometry(geomType.polygon);
wfsAreaType_current = wfsAreaType_polygon;
- mod_wfs_spatialRequest_digitize_go(geomType.polygon);
+ mod_wfs_spatialRequest_digitize_go(geomType.polygon);
var measureSub = "";
for(var i=0; i<mod_wfs_spatialRequestSubFunctions.length; i++){
measureSub += eval(mod_wfs_spatialRequestSubFunctions[i]);
- }
+ }
writeTag(mod_wfs_spatialRequest_target,"measure_sub",measureSub);
}
else if (obj.id == button_rectangle){
@@ -197,7 +197,7 @@
}
mod_wfs_spatialRequest_geometry = new Geometry(geomType.line);
wfsAreaType_current = wfsAreaType_rectangle;
- mod_selAreaExt_click();
+ mod_selAreaExt_click();
}
else if (obj.id == button_extent){
if (activeButton == null) {
@@ -207,7 +207,7 @@
wfsAreaType_current = wfsAreaType_extent;
var ind = getMapObjIndexByName(mod_wfs_spatialRequest_target);
var p0 = mapToReal(mod_wfs_spatialRequest_target, new Point(0,0));
- var p1 = mapToReal(mod_wfs_spatialRequest_target, new Point(mb_mapObj[ind].width,mb_mapObj[ind].height));
+ var p1 = mapToReal(mod_wfs_spatialRequest_target, new Point(mb_mapObj[ind].width,mb_mapObj[ind].height));
mod_wfs_spatialRequest_geometry.addPoint(p0);
mod_wfs_spatialRequest_geometry.addPoint(p1);
mod_getAreaExt_send();
@@ -219,7 +219,7 @@
}
function wfsDisable(obj) {
- var el = window.frames[mod_wfs_spatialRequest_target].document;
+ var el = window.frames[mod_wfs_spatialRequest_target].document;
el.onmousedown = null;
el.ondblclick = null;
el.onmousemove = null;
@@ -253,7 +253,7 @@
if (mod_wfs_spatialRequest_geometry != null) {
mod_wfs_spatialRequest_geometry.addPoint(new Point(coords[0],coords[1]));
mod_wfs_spatialRequest_geometry.addPoint(new Point(coords[2],coords[3]));
-
+
if(mod_wfs_spatialRequest_geometry.count() == 2){
mod_getAreaExt_send();
}
@@ -281,7 +281,7 @@
var measureSub = "";
for(var i=0; i<mod_wfs_spatialRequestSubFunctions.length; i++){
measureSub += eval(mod_wfs_spatialRequestSubFunctions[i]);
- }
+ }
writeTag(mod_wfs_spatialRequest_target,"measure_sub",measureSub);
}
@@ -298,7 +298,7 @@
function mod_wfs_spatialRequest_start(e){
var realWorldPos;
if (s.isSnapped() == true) {
- realWorldPos = s.getSnappedPoint();
+ realWorldPos = s.getSnappedPoint();
s.clean();
}
else {
@@ -316,7 +316,7 @@
mod_getAreaExt_send();
return;
}
-
+
if(wfsAreaType_current == wfsAreaType_point){
mod_getAreaExt_send();
return;
@@ -347,7 +347,7 @@
var n = Math.round(d);
var s = p0.minus(p1).dividedBy(n);
for(var i=1; i<n; i++){
- var currPoint = p1.plus(s.times(i)).minus(new Point(2,2)).round(0);
+ var currPoint = p1.plus(s.times(i)).minus(new Point(2,2)).round(0);
if(currPoint.x >= 0 && currPoint.x <= mod_wfs_spatialRequest_width && currPoint.y >= 0 && currPoint.y <= mod_wfs_spatialRequest_height){
str_dashedLine += "<div style='font-size:1px;position:absolute;top:"+currPoint.y+"px;left:"+currPoint.x+"px;width:3px;height:3px;background-color:#ff0000'></div>";
}
@@ -367,7 +367,7 @@
mod_wfs_spatialRequestSubFunctions[mod_wfs_spatialRequestSubFunctions.length] = stringFunction;
}
-function mod_getAreaExt_send(){
+function mod_getAreaExt_send(){
mb_setwfsrequest(mod_wfs_spatialRequest_target,mod_wfs_spatialRequest_geometry);
mod_wfs_spatialRequest_delete();
mb_disableThisButton(activeButton.id);
@@ -380,7 +380,7 @@
}
function mod_wfs_spatialRequest_timeout(){
- var el = window.frames[mod_wfs_spatialRequest_target].document;
+ var el = window.frames[mod_wfs_spatialRequest_target].document;
el.onmousedown = null;
el.ondblclick = null;
el.onmousemove = null;
@@ -396,16 +396,16 @@
return false;
}
-function mod_wfs_SpatialRequest_dialog(){
+function mod_wfs_SpatialRequest_dialog(){
if(!mod_wfs_spatialRequest_win || mod_wfs_spatialRequest_win == null || mod_wfs_spatialRequest_win.closed == true){
mod_wfs_spatialRequest_win = window.open("","mod_wfs_spatialRequest_win","width=200,height=150,resizable=yes");
mod_wfs_spatialRequest_win.document.open("text/html");
-
- mod_wfs_spatialRequest_win.document.writeln('<script language="JavaScript" type="text/javascript">');
+
+ mod_wfs_spatialRequest_win.document.writeln('<script language="JavaScript" type="text/javascript">');
mod_wfs_spatialRequest_win.document.writeln('function set(obj){');
mod_wfs_spatialRequest_win.document.writeln('for(var i=0; i< document.getElementsByName("geom").length; i++){');
mod_wfs_spatialRequest_win.document.writeln('if(document.getElementsByName("geom")[i].checked){');
- mod_wfs_spatialRequest_win.document.writeln('window.opener.mod_setExtRequest_geom = document.getElementsByName("geom")[i].value;');
+ mod_wfs_spatialRequest_win.document.writeln('window.opener.mod_setExtRequest_geom = document.getElementsByName("geom")[i].value;');
mod_wfs_spatialRequest_win.document.writeln('}');
mod_wfs_spatialRequest_win.document.writeln('}');
mod_wfs_spatialRequest_win.document.writeln('window.opener.wfsEnable(obj);');
@@ -413,7 +413,7 @@
mod_wfs_spatialRequest_win.document.writeln('return false; ');
mod_wfs_spatialRequest_win.document.writeln('}');
mod_wfs_spatialRequest_win.document.writeln('</script>');
-
+
mod_wfs_spatialRequest_win.document.writeln("<form>");
mod_wfs_spatialRequest_win.document.writeln("<input id='point' name='geom' type='radio' value='"+button_point+"' onclick='set(this)'> Punkt<br>");
mod_wfs_spatialRequest_win.document.writeln("<input id='rectangle' name='geom' type='radio' value='"+button_rectangle+"' onclick='set(this)'> Rechteck<br>");
@@ -425,49 +425,50 @@
}
else{
mod_wfs_spatialRequest_win.focus();
- }
+ }
}
function mb_setwfsrequest(target,queryGeom){
if (typeof(wfsPopup) != "undefined") {
wfsPopup.hide();
- }
+ }
//mb_wfs_reset();
var ind = getMapObjIndexByName(target);
var db_wfs_conf_id = [];
js_wfs_conf_id = [];
_geomArray = new GeometryArray();
-
+
if (typeof(resultGeometryPopup) != "undefined") {
resultGeometryPopup.hide();
}
-
+
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'){
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++){
+ 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;
-
+
if(queryGeom.geomType==geomType.polygon){
for(var i=0; i<js_wfs_conf_id.length; i++){
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=";
var filter = "<ogc:Filter xmlns:ogc=\"http://ogc.org\" xmlns:gml=\"http://www.opengis.net/gml\">";
-
- if(buttonPolygon.filteroption=='within'){
+
+ if(buttonPolygon.filteroption=='within'){
filter += "<Within><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){
@@ -491,7 +492,7 @@
}
}
filter += "</ogc:PropertyName><gml:Polygon srsName='4326'>";
- filter += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
for(var k=0; k<queryGeom.count(); k++){
if(k>0) filter += " ";
filter += queryGeom.get(k).x+","+queryGeom.get(k).y;
@@ -499,7 +500,7 @@
filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
filter += "</gml:Polygon></Intersects>";
}
-
+
filter += '</ogc:Filter>';
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]);
}
@@ -511,10 +512,11 @@
}
for(var i=0; i<js_wfs_conf_id.length; i++){
var url = wfs_config[js_wfs_conf_id[i]]['wfs_getfeature'];
+ url += mb_getConjunctionCharacter(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'>";
-
- if(buttonRectangle.filteroption=='within'){
+
+ if(buttonRectangle.filteroption=='within'){
filter += "<Within><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){
@@ -543,7 +545,7 @@
}
}
filter += "</ogc:PropertyName><gml:Polygon srsName='4326'>";
- filter += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ filter += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
filter += rectangle[0].x+","+rectangle[0].y;
filter += " ";
filter += rectangle[0].x+","+rectangle[1].y;
@@ -555,8 +557,8 @@
filter += rectangle[0].x+","+rectangle[0].y;
filter += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
filter += "</gml:Polygon></Intersects>";
- }
-
+ }
+
filter += "</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]);
@@ -566,7 +568,7 @@
var tmp = queryGeom.get(0);
var mapPos = makeRealWorld2mapPos("mapframe1",tmp.x, tmp.y);
var buffer = mb_wfs_tolerance/2;
- var mapPosXAddPix = mapPos[0] + buffer;
+ var mapPosXAddPix = mapPos[0] + buffer;
var mapPosYAddPix = mapPos[1] +buffer;
var mapPosXRemovePix = mapPos[0] - buffer;
var mapPosYRemovePix = mapPos[1] - buffer;
@@ -576,6 +578,7 @@
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'];
+ url += mb_getConjunctionCharacter(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>";
@@ -584,9 +587,9 @@
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 += "</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 += 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]);
@@ -597,7 +600,7 @@
}
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);
@@ -618,7 +621,7 @@
if (numberOfFinishedAjaxCalls == numberOfAjaxCalls) {
numberOfFinishedAjaxCalls = 0;
mb_execWfsReadSubFunctions(_geomArray);
-
+
}
}
@@ -648,7 +651,7 @@
}
else {
resultArray[pos] = geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']);
- }
+ }
resultName += geom.e.getElementValueByName(wfsConf[wfsConfId]['element'][i]['element_name']) + " ";
}
}
@@ -683,7 +686,7 @@
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";
+ listOfGeom += "<tr>\n<td> </td>\n</tr>\n";
}
for (var i = 0 ; i < _geomArray.count(); i ++) {
if (_geomArray.get(i).get(-1).isComplete()) {
@@ -691,7 +694,7 @@
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+")); showWfs("+i+");' ";
- var geomName = getListTitle(_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)";}
@@ -699,12 +702,12 @@
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 += "\t\t</tr>\n";
}
}
}
listOfGeom += "</table>\n";
- return listOfGeom;
+ return listOfGeom;
}
function displayPopup(geom){
@@ -722,18 +725,18 @@
function showWfs(geometryIndex) {
var wfsConfIndex = _geomArray.get(geometryIndex).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 +="<tr><td>\n";
resultHtml += currentWfsConf.element[i].f_label;
- resultHtml +="</td>\n";
+ resultHtml +="</td>\n";
resultHtml += "<td>\n";
- var elementVal = _geomArray.get(geometryIndex).e.getElementValueByName(currentWfsConf.element[i].element_name);
+ 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>/)){
@@ -744,18 +747,18 @@
}
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 += "</td></tr>\n";
}
}
}
resultHtml += "</table>\n";
-
+
var getCenter = _geomArray.get(geometryIndex).getCenter();
// getMapPos for positioning of new PopupDiv near object in mapframe1
//var getMapPos = makeRealWorld2mapPos("mapframe1",getCenter.x, getCenter.y);
@@ -776,4 +779,4 @@
}
if(wfsResultToPopupDiv==1){
mb_registerWfsReadSubFunctions(function(geom){displayPopup(geom);});
-}
+}
\ No newline at end of file
More information about the Mapbender_commits
mailing list