[Mapbender-commits] r6481 - in trunk/mapbender: http/plugins lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Jul 1 07:40:43 EDT 2010


Author: kmq
Date: 2010-07-01 11:40:43 +0000 (Thu, 01 Jul 2010)
New Revision: 6481

Modified:
   trunk/mapbender/http/plugins/mb_selectorwizard.js
   trunk/mapbender/http/plugins/mb_wfsGazetteer.js
   trunk/mapbender/lib/mb.ui.wfsGazetteer.js
   trunk/mapbender/lib/wizard.js
Log:
mb.ui.wfsGazetteer recognizes spatial buttons

Modified: trunk/mapbender/http/plugins/mb_selectorwizard.js
===================================================================
--- trunk/mapbender/http/plugins/mb_selectorwizard.js	2010-07-01 11:40:43 UTC (rev 6480)
+++ trunk/mapbender/http/plugins/mb_selectorwizard.js	2010-07-01 11:40:43 UTC (rev 6481)
@@ -9,12 +9,12 @@
 		onNavigate : new Mapbender.Event()
 	};
 	
-	$select = $('<select></select>');
+	$select = $('select',$wizard);
 	
 	Mapbender.events.init.register(function () {
 		if (o.$target.size() > 0) {
 			$wizard.append(o.$target).wizard({
-				fade: true,
+				fade: false,
 				startWith: o.$target.eq(0),
 				onClickLink: function ($targets) {
 					that.events.onClickLink.trigger({
@@ -35,7 +35,6 @@
 		}
 	});
 
-	$wizard.prepend($select);
 	o.$target.each(function(){
 		$option = $('<option></option>').attr('value',this.id).text($(this).attr('title'));
 		$select.append($option);
@@ -43,6 +42,22 @@
 	$select.change(function(){
 		$wizard.wizard('to',$('#' + $(this).val()));
 	});
+			
+	//TODO: this allows a user to use a html <button> elemnt  to create spatial buttons
+	// but the implementation needs work
+	$('button.mb-ui-searchContainer-point', $wizard).each(function(e){
+		$(this).replaceWith($('#mb_digitize_point'));
+	});
+	$('button.mb-ui-searchContainer-line', $wizard).each(function(e){
+		$(this).replaceWith($('#mb_digitize_line'));
+	});
+	$('button.mb-ui-searchContainer-polygon', $wizard).each(function(e){
+		$(this).replaceWith($('#mb_digitize_polygon'));
+	});
+	$('button.mb-ui-searchContainer-rectangle', $wizard).each(function(e){
+		$(this).replaceWith($('#mb_digitize_rectangle'));
+	});
+
 	
 };
 

Modified: trunk/mapbender/http/plugins/mb_wfsGazetteer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_wfsGazetteer.js	2010-07-01 11:40:43 UTC (rev 6480)
+++ trunk/mapbender/http/plugins/mb_wfsGazetteer.js	2010-07-01 11:40:43 UTC (rev 6481)
@@ -10,7 +10,7 @@
 }, function(json, status) {
 	var wfsConf = $.parseJSON(json);
 	$gazetteer.wfsGazetteer({
-		target: $target,
+		target: options.$target,
 		wfsConf: wfsConf[options.wfsConf],
 		receivefeaturecollection : function(e,data){
 			// trigger compatibility event for wfsGazeteer ? 	
@@ -23,8 +23,15 @@
 		}
 	});
 
-	mapbender.modules.mb_digitize_point.events.finished.register(function(obj, b ,c){
-	debugger;
+});
 
+Mapbender.events.init.register(function () {
+	options.$target.each(function(){
+		if(this.id && Mapbender.modules[this.id]){
+			Mapbender.modules[this.id].events.finished.register(function(obj){
+				var fc = $.parseJSON(obj.featureCollection);
+				$gazetteer.wfsGazetteer('option', 'geometry',fc.features[0]);
+			});
+		}
 	});
 });

Modified: trunk/mapbender/lib/mb.ui.wfsGazetteer.js
===================================================================
--- trunk/mapbender/lib/mb.ui.wfsGazetteer.js	2010-07-01 11:40:43 UTC (rev 6480)
+++ trunk/mapbender/lib/mb.ui.wfsGazetteer.js	2010-07-01 11:40:43 UTC (rev 6481)
@@ -2,7 +2,7 @@
 
 $.widget("mb.wfsGazetteer", {
 	options: {
-		
+		geometry : null
 	},
 
 	_create: function () {
@@ -52,6 +52,8 @@
 			}).text(el.f_label).append($formElement);
 
 			$(".mb-ui-wfsGazetteer-form", this.element).prepend($label);
+		
+
 		}
 
 		$(this.element).submit(function(e){
@@ -93,13 +95,13 @@
 		var OGCFilterExpression = "";
 		var orConditions = [];
 		var andConditions  = [];
-		for(var j = 0; i < this.options.wfsConf.element.length; i++){
+		for(var i = 0; i < this.options.wfsConf.element.length; i++){
 			el = this.options.wfsConf.element[i];
 			id = $(this.element).attr('id') + "_" + el.element_name;
 
-			var qname = el.element_name.split(':');	
-			nsPrefix = qname.length == 2 ? qname[1]+":" : "";
-			elementQname = nsPrefix + el.element_name
+			var qname = ft.split(':');	
+			nsPrefix = qname.length == 2 ? qname[0]+":" : "";
+			elementQname = nsPrefix + el.element_name;
 			value = $('#'+id).val() || "";
 			
 			// check if field is mandatory
@@ -116,60 +118,60 @@
 			switch(el.f_operator){
 				
 				case 'greater_than':
-					OGCFilterExpression  = "<OGC:PropertyIsGreaterThan>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsGreaterThan>";
+					OGCFilterExpression  = "<ogc:PropertyIsGreaterThan>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsGreaterThan>";
 				break;
 				
 				case 'greater_equal_than':
-					OGCFilterExpression  = "<OGC:PropertyIsGreaterThanOrEqualTo>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsGreaterThanOrEqualTo>";
+					OGCFilterExpression  = "<ogc:PropertyIsGreaterThanOrEqualTo>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsGreaterThanOrEqualTo>";
 				break;
 				
 				case 'less_than':
-					OGCFilterExpression  = "<OGC:PropertyIsLessThan>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsLessThan>";
+					OGCFilterExpression  = "<ogc:PropertyIsLessThan>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsLessThan>";
 				break;
 				
 				case 'less_equal_than':
-					OGCFilterExpression  = "<OGC:PropertyIsLessThan>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsLessThan>";
+					OGCFilterExpression  = "<ogc:PropertyIsLessThan>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsLessThan>";
 				break;
 				
 				case 'equal':
-					OGCFilterExpression  = "<OGC:PropertyIsEqualTo>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsEqualTo>";
+					OGCFilterExpression  = "<ogc:PropertyIsEqualTo>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsEqualTo>";
 				break;
 			
 				case 'leftside':
-					OGCFilterExpression  = "<OGC:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>*"+value+"</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsLike>";
+					OGCFilterExpression  = "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>*"+value+"</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsLike>";
 				break;
 			
 				case 'rightside':
-					OGCFilterExpression  = "<OGC:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsLike>";
+					OGCFilterExpression  = "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>"+value+"*</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsLike>";
 				break;
 				
 				case 'bothside':
 				default:
-					OGCFilterExpression  = "<OGC:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-					OGCFilterExpression += "<OGC:propertyName>"+ elementQname +"</OGC:propertyName>";
-					OGCFilterExpression += "<OGC:Literal>*"+value+"*</OGC:Literal>";	
-					OGCFilterExpression += "</OGC:PropertyIsLike>";
+					OGCFilterExpression  = "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname +"</ogc:PropertyName>";
+					OGCFilterExpression += "<ogc:Literal>*"+value+"*</ogc:Literal>";	
+					OGCFilterExpression += "</ogc:PropertyIsLike>";
 				break;
 				
 				
@@ -177,26 +179,70 @@
 
 			orConditions.push(OGCFilterExpression);	
 		}
-		var OGCORFilter = orConditions.length == 1 ? orConditions[0] : "<Or>"+ orConditions.join('') +"<Or>"; 
+		var OGCORFilter = orConditions.length == 1 ? orConditions[0] : "<Or>"+ orConditions.join('') +"</Or>"; 
 		andConditions.push(OGCORFilter);
 
-		//TODO: spatial filter
-		var geometryConstructor = RequestGeometryConstructor(target);
-		geometryConstructor.getGeometry(this.options.target ,function(target,queryGeom){
-			switch(queryGeom.type){
-				case geomType.line :
+
+		
+
+		for(var i = 0; i < this.options.wfsConf.element.length; i++){
+			el = this.options.wfsConf.element[i];
+			if(el.f_geom != 1 || this.options.geometry == null){ continue; }
+			var geometry = this.options.geometry;
+			console.log("geometry is :"+ geometry);
+			var qname = ft.split(':');	
+			nsPrefix = qname.length == 2 ? qname[0]+":" : "";
+			elementQname = nsPrefix  +el.element_name;
+			OGCFilterExpression = "";
+			switch(geometry.geomType){
+
+				case geomType.point:
+					//var mapPos = makeRealWorld2mapPos("mapframe1",geometry.get(0).x, geometry.get(0).y);
+					//mapPos = makeClickPos2RealWorldPos("mapframe1", geometry.get(0).x, geometry.get(0).y);
+					
+					var mapPos = [geometry.get(0).x,geometry.get(0).y];
+					var buffer = 4;
+					var mapPosXAddPix = mapPos[0] + buffer; 
+					var mapPosYAddPix = mapPos[1] +buffer;
+					var mapPosXRemovePix = mapPos[0] - buffer;
+					var mapPosYRemovePix = mapPos[1] - buffer;
+					var realWorld1 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+					var realWorld2 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+					var realWorld3 = makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYAddPix);
+					var realWorld4 = makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+					OGCFilterExpression = "<Intersects><ogc:PropertyName>";
+					OGCFilterExpression +=  elementQname;
+					OGCFilterExpression += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+					OGCFilterExpression += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
+					OGCFilterExpression += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1]; 
+					OGCFilterExpression += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
 				break;
 
-				default:
+				case geomType.line:
+
+				break;
+
+				case geomType.polygon:
+					OGCFilterExpression += "<ogc:PropertyName>"+ elementQname  +"</ogc:PropertyName>";
+					OGCFilterExpression += '<gml:Polygon srsName="'+srs + '"><gml:outerBoundaryIs><gml:LinearRing>';
+					OGCFilterExpression += '<gml:coordinates>';
+					for(var k=0; k<geometry.count(); k++){
+						if(k>0)	{ OGCFilterExpression += " ";}
+						OGCFilterExpression += geometry.get(k).x+","+geometry.get(k).y;
+					}
+					OGCFilterExpression += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>';
+					OGCFilterExpression ="<Intersects>" + OGCFilterExpression +"</Intersects>";
+				break;
 			}
-		});
+			andConditions.push(OGCFilterExpression);
+		}
 
-		var OGCANDFilter = andConditions.length == 1 ? andConditions[0] : "<And>"+ andConditions.join('') +"<and>"; 
-		OGCFilter = "<ogc:filter>" + OGCANDFilter  +"</ogc:filter>";
+		var OGCANDFilter = andConditions.length == 1 ? andConditions[0] : "<And>"+ andConditions.join('') +"</And>"; 
+		OGCFilter = "<ogc:Filter>" + OGCANDFilter  +"</ogc:Filter>";
 		
 		var params = {
 			command : "getSearchResults", 
-			wfs_conf_id : this.options.wfsConf.wfs_id, //?
+			wfs_conf_id : this.options.wfsConf.wfs_conf_id, //?
 			typename : this.options.wfsConf.featuretype_name,
 			frame : "", 
 			filter : OGCFilter, 
@@ -211,6 +257,18 @@
 
 
 	},
+	_setOption: function(key,value){
+		switch(key){
+			case "geometry":
+				var geomArray = new GeometryArray();
+				geomArray.importGeoJSON(value);
+				var geometry = geomArray.get(0).get(0);
+				this.options.geometry = geometry;
+				console.log(geometry);
+			break;
+
+		}
+	},
 	receivefeaturecollection: function(event,ui){
 	},
 	_status: function(message){

Modified: trunk/mapbender/lib/wizard.js
===================================================================
--- trunk/mapbender/lib/wizard.js	2010-07-01 11:40:43 UTC (rev 6480)
+++ trunk/mapbender/lib/wizard.js	2010-07-01 11:40:43 UTC (rev 6481)
@@ -14,12 +14,12 @@
 	},
 	_navigate: function ($t) {
 		if (this.options.fade) {
-			$t.siblings("div").fadeOut(function () {
+			$t.siblings("div,form,iframe").fadeOut(function () {
 				$t.fadeIn();
 			});
 		}		
 		else {
-			$t.siblings("div").hide();
+			$t.siblings("div,form,iframe").hide();
 			$t.show();
 		}
 	},



More information about the Mapbender_commits mailing list