[Mapbender-commits] r4024 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue Jun 16 04:03:53 EDT 2009
Author: christoph
Date: 2009-06-16 04:03:53 -0400 (Tue, 16 Jun 2009)
New Revision: 4024
Modified:
trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
Log:
and COnditions are no longer string but array
this allows to check whether only one and condition exists; in this case, you don't need an <And> brace around the filter
Modified: trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php 2009-06-16 04:54:08 UTC (rev 4023)
+++ trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php 2009-06-16 08:03:53 UTC (rev 4024)
@@ -731,7 +731,7 @@
}
else{
if(inputNotEnough.length==0){
- var andConditions = "";
+ var andConditions = [];
var el = global_wfsConfObj[global_selectedWfsConfId].element;
var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
@@ -867,49 +867,50 @@
}
}
if(a.length > 1){
- andConditions += "<Or>" + orConditions + "</Or>";
+ andConditions.push("<Or>" + orConditions + "</Or>");
}
else {
- andConditions += orConditions;
+ andConditions.push(orConditions);
}
}
}
if(spatialRequestGeom!=null){
+ var currentAndCondition = "";
if(spatialRequestGeom.geomType == "polygon"){
if(buttonPolygon.filteroption=='within'){
- andConditions += "<Within><ogc:PropertyName>";
+ currentAndCondition = "<Within><ogc:PropertyName>";
for (var j=0; j < el.length; j++) {
if(el[j]['f_geom']==1){
var elementName = el[j]['element_name'];
- andConditions += el[j]['element_name'];
+ currentAndCondition += el[j]['element_name'];
}
}
- andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
- andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
for(var k=0; k<spatialRequestGeom.count(); k++){
- if(k>0) andConditions += " ";
- andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+ if(k>0) currentAndCondition += " ";
+ currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
}
- andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
- andConditions += "</gml:Polygon></Within>";
+ currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ currentAndCondition += "</gml:Polygon></Within>";
}
else if(buttonPolygon.filteroption=='intersects'){
- andConditions += "<Intersects><ogc:PropertyName>";
+ currentAndCondition = "<Intersects><ogc:PropertyName>";
for (var j=0; j < el.length; j++) {
if(el[j]['f_geom']==1){
var elementName = el[j]['element_name'];
- andConditions += el[j]['element_name'];
+ currentAndCondition += el[j]['element_name'];
}
}
- andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
- andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
for(var k=0; k<spatialRequestGeom.count(); k++){
- if(k>0) andConditions += " ";
- andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+ if(k>0) currentAndCondition += " ";
+ currentAndCondition += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
}
- andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
- andConditions += "</gml:Polygon></Intersects>";
+ currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ currentAndCondition += "</gml:Polygon></Intersects>";
}
}
else if(spatialRequestGeom.geomType == "line"){
@@ -917,48 +918,48 @@
rectangle = spatialRequestGeom.getBBox();
if(buttonRectangle.filteroption=='within'){
- andConditions += "<Within><ogc:PropertyName>";
+ currentAndCondition = "<Within><ogc:PropertyName>";
for (var j=0; j < el.length; j++) {
if(el[j]['f_geom']==1){
var elementName = el[j]['element_name'];
- andConditions += el[j]['element_name'];
+ currentAndCondition += el[j]['element_name'];
}
}
- andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
- andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
- andConditions += rectangle[0].x+","+rectangle[0].y;
- andConditions += " ";
- andConditions += rectangle[0].x+","+rectangle[1].y;
- andConditions += " ";
- andConditions += rectangle[1].x+","+rectangle[1].y;
- andConditions += " ";
- andConditions += rectangle[1].x+","+rectangle[0].y;
- andConditions += " ";
- andConditions += rectangle[0].x+","+rectangle[0].y;
- andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
- andConditions += "</gml:Polygon></Within>";
+ currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[0].x+","+rectangle[1].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[1].x+","+rectangle[1].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[1].x+","+rectangle[0].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+ currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ currentAndCondition += "</gml:Polygon></Within>";
}
else if(buttonRectangle.filteroption=='intersects'){
- andConditions += "<Intersects><ogc:PropertyName>";
+ currentAndCondition = "<Intersects><ogc:PropertyName>";
for (var j=0; j < el.length; j++) {
if(el[j]['f_geom']==1){
var elementName = el[j]['element_name'];
- andConditions += el[j]['element_name'];
+ currentAndCondition += el[j]['element_name'];
}
}
- andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
- andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
- andConditions += rectangle[0].x+","+rectangle[0].y;
- andConditions += " ";
- andConditions += rectangle[0].x+","+rectangle[1].y;
- andConditions += " ";
- andConditions += rectangle[1].x+","+rectangle[1].y;
- andConditions += " ";
- andConditions += rectangle[1].x+","+rectangle[0].y;
- andConditions += " ";
- andConditions += rectangle[0].x+","+rectangle[0].y;
- andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
- andConditions += "</gml:Polygon></Intersects>";
+ currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+ currentAndCondition += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[0].x+","+rectangle[1].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[1].x+","+rectangle[1].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[1].x+","+rectangle[0].y;
+ currentAndCondition += " ";
+ currentAndCondition += rectangle[0].x+","+rectangle[0].y;
+ currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+ currentAndCondition += "</gml:Polygon></Intersects>";
}
}
else if(spatialRequestGeom.geomType == "point"){
@@ -973,28 +974,33 @@
var realWorld2 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
var realWorld3 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYAddPix);
var realWorld4 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
- andConditions += "<Intersects><ogc:PropertyName>";
+ currentAndCondition = "<Intersects><ogc:PropertyName>";
for (var j=0; j < el.length; j++) {
if(el[j]['f_geom']==1){
var elementName = el[j]['element_name'];
- andConditions += el[j]['element_name'];
+ currentAndCondition += el[j]['element_name'];
}
}
- andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
- andConditions += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
- andConditions += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
- andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
+ currentAndCondition += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+ currentAndCondition += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] + " ";
+ currentAndCondition += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1];
+ currentAndCondition += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
}
//andConditions += "<ogc:Not><ogc:PropertyIsNull>";
//andConditions += "<ogc:PropertyName>" + elementName + "</ogc:PropertyName>";
//andConditions += "</ogc:PropertyIsNull></ogc:Not>";
+ if (currentAndCondition !== "") {
+ andConditions.push(currentAndCondition);
+ }
+
}
- if (filterParameterCount > 1 || spatialRequestGeom != null) {
- andConditions = "<And>" + andConditions + "</And>";
+ var andConditionString = andConditions.join("");
+ if (andConditions.length > 1) {
+ andConditionString = "<And>" + andConditionString + "</And>";
}
- var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+ var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditionString+"</ogc:Filter>";
document.getElementById("res").innerHTML = "<table><tr><td><img src='"+progressIndicatorImg+"'></td><td>"+progressIndicatorText+"</td></tr></table>";
var parameters = {
@@ -1288,6 +1294,6 @@
<div name='displaySpatialButtons' id='displaySpatialButtons' style='width:180px;margin-top:5px;background-color:#FFFFFF;'></div>
<form name='wfsForm' id='wfsForm' onsubmit='return validate()'>
</form>
-<div class='resultDiv' name='res' id='res' style='width:180px'></div>
+<div name='res' id='res' style='width:180px'></div>
</body>
</html>
More information about the Mapbender_commits
mailing list