[Mapbender-commits] r5062 - trunk/mapbender/lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Dec 3 03:54:20 EST 2009


Author: kmq
Date: 2009-12-03 03:54:19 -0500 (Thu, 03 Dec 2009)
New Revision: 5062

Added:
   trunk/mapbender/lib/resultGeometryListController.js
Log:
First stages of GeometryListController

Added: trunk/mapbender/lib/resultGeometryListController.js
===================================================================
--- trunk/mapbender/lib/resultGeometryListController.js	                        (rev 0)
+++ trunk/mapbender/lib/resultGeometryListController.js	2009-12-03 08:54:19 UTC (rev 5062)
@@ -0,0 +1,127 @@
+//var geojson = {"type": "FeatureCollection", "features": [{"type":"Feature", "id":"mapbender_user.607322", "crs":{"type":"name", "properties":{"name":"http://www.opengis.net/gml/srs/epsg.xml#4326"}}, "geometry": {"type": "Point", "coordinates":[-74.0517,4.6261]}, "properties": {"gid":"746","firstname":"Diego Fabian","lastname":"Pajarito Grajales","usertype":"1","orga":"IGAC - CIAF","town":"Colombia","fullname":"www.igac.gov.co"}}];
+
+var ResultGeometryListController = function(options){
+
+	// The WFSConfId this List is currently configured with
+	var WFSConfId = null;
+
+	// our model
+	var model = null;
+
+	// a jquery obect referencing the datatable we're using
+	var datatable = null;
+
+	// the columns that should be displayed
+	var columns = [];
+
+
+	// adding
+	this.addFeature = function(feature) {
+		if (this.wfsConfId === null){
+			// or throw an exception?
+			return false;
+		}
+		var result = this.model.addFeature(feature);
+	};
+
+	// featureCollection is geoJSON
+	this.addFeatureCollection = function(featureCollection){
+		var result = this.model.addFeatureCollection(featureCollection);
+	};
+
+	//called if a FeatureCollection was successfully added to the model
+	var addFeatureCollection_callback = function(featureEntryCollection){
+	// featureEntryCollection is an array of {index: <index>, feature: <feature>}
+	// where <index> is the index in the model, and feature a featuireCollection
+		
+		// only add feature.properties enabled by wfsConf
+		for (featureEntry in featureCollection){
+			//create array from featureEntries.feature here, using  wfsconf
+			var rowData = array("test");
+
+			// fnAddData returns an array of indices
+			var index = this.datatable.fnAddData(rowData);
+
+			// this is ok because we only added a single row
+			var nowNode = this.datatable.fnGetNodes(index[0]);
+			$.data(rowNode,"modelindex",featuresEntry.index);
+		}
+	};
+	
+	//deleting
+	// from where is this called ?
+	this.deleteFeature = function(DOMTableRow){
+		var modelIndex = $.data(DOMTableRow,"modelIndex");
+		this.model.deleteFeature(modelIndex);
+	 };
+
+	//called to config deletion was successfull
+	this.deleteFeature_callback = function(featureEntry){
+	};
+
+	//updating
+
+
+	// clear = reinitialize + setting WFSConf to same value again ?
+
+	//misc
+	this.setWFSconf = function(WFSConfId) {
+		if(WFSConfId != this.WFSConfId){
+			_reinitialize();
+			this.WFSConfId = WFSConfId;
+			
+		}
+	};
+
+	var getColumns  = function(WfsConfId){
+		return array("TESTLABEL");
+		var currentWfsConf = global_wfsConfObj[currentWfsConfId];
+		var labelArray = [];
+		for (var j = 0 ; j < currentWfsConf.element.length ; j++) {
+			if(currentWfsConf.element[j].f_show == 1 && currentWfsConf.element[j].f_label!==''){
+				var labelPos = currentWfsConf.element[j].f_respos;
+				labelArray[labelPos] = currentWfsConf.element[j].f_label;
+			}
+		}
+		return labelArray;
+	};
+
+	var reinitialize = function(){
+	
+		// clear old
+		if($('#'+options.id+"_table").size() !== 0)
+		{
+			$('#'+options.id).remove();
+		}
+		
+			
+
+
+		// initialize new
+		model = new ResultGeometryListModel();
+
+		model.events.added.register(this.addFeatureCollection_callback);
+		model.events.deleted.register();
+		model.events.updated.register();
+		model.events.cleared.register(this.reinitialize);
+
+
+		var table = $('#'+options.id).append("<table id="+ options.id+"_table" + "></table");
+		
+		//create theads, and variable "labels" according to wfsConf
+		this.columns = this.getColumns(this.WFSConfId);
+		var heads = $("<thead></thead>");
+		for (column in columns)
+		{
+			heads.append($("<th>"+column+"</th>"));
+		}
+		table.append(heads);
+		this.datatable = $('#'+options.id+"_table").dataTable();
+
+
+	};
+	reinitialize();
+	
+};
+
+//Mapbender.modules[options.id] = $.extend(new resultGemoetryListController(options), Mapbender.modules[options.id])



More information about the Mapbender_commits mailing list