[Mapbender-commits] r8463 - in trunk/mapbender/http: javascripts plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 21 23:20:03 PDT 2012


Author: armin11
Date: 2012-08-21 23:20:01 -0700 (Tue, 21 Aug 2012)
New Revision: 8463

Modified:
   trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
   trunk/mapbender/http/plugins/mb_downloadFeedClient.php
Log:
Bugfixes

Modified: trunk/mapbender/http/javascripts/mb_downloadFeedClient.js
===================================================================
--- trunk/mapbender/http/javascripts/mb_downloadFeedClient.js	2012-08-20 13:41:19 UTC (rev 8462)
+++ trunk/mapbender/http/javascripts/mb_downloadFeedClient.js	2012-08-22 06:20:01 UTC (rev 8463)
@@ -1,6 +1,6 @@
 var mapframe_dataset_list, mapframe_file_list, datasetSelect, file_list, bboxDataset, bboxFiles, formats, sf;
 
-        function updateFormats() {
+function updateFormats() {
             var in_options = {
                 'internalProjection': mapframe_dataset_list.baseLayer.projection,
                 'externalProjection': new OpenLayers.Projection("EPSG:4326")
@@ -44,15 +44,13 @@
                 atom: new OpenLayers.Format.Atom(out_options),
                 gpx: new OpenLayers.Format.GPX(out_options)
               } 
-            };
-        }
+	};
+}
 
 function init(){
 	//generate 2 Mapframes
 	mapframe_dataset_list = new OpenLayers.Map('mapframe_dataset_list');
-
 	mapframe_file_list = new OpenLayers.Map('mapframe_file_list');
-
 	var wms1 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                 "http://www.gdi-rp-dienste2.rlp.de/cgi-bin/mapserv.fcgi?map=/data/umn/geoportal/karte_rp/rheinland-pfalz-gesamt2.map&", {layers: 'ATKIS-Praes'}, {singleTile: true});
 	var wms2 = new OpenLayers.Layer.WMS( "OpenLayers WMS",
@@ -61,13 +59,10 @@
 	bboxDataset = new OpenLayers.Layer.Vector("Dataset bounding boxes");
 	//Vector layer for the georss polygons of one single data feed entry - maybe more than one if the dataset is tiled into different sections 
 	bboxFiles = new OpenLayers.Layer.Vector("File bounding boxes");
-
 	mapframe_dataset_list.addLayers([wms1, bboxDataset]);
 	mapframe_dataset_list.addControl(new OpenLayers.Control.MousePosition());
-
 	mapframe_file_list.addLayers([wms2, bboxFiles]);
 	mapframe_file_list.addControl(new OpenLayers.Control.MousePosition());
-
 	updateFormats();
 	//initialize mapframes
 	mapframe_dataset_list.setCenter(new OpenLayers.LonLat(7, 50), 7);
@@ -88,7 +83,10 @@
 			callServer(data,method);
     		});
 	});
+	//don't show elements of dataset feed
+	resetForm();
 }
+
 //central function to call server by ajax, result is a featureCollection which is generated by mapbenders server component
 function callServer(data,method,id) {
 	if (id === undefined) id = 0;
@@ -116,7 +114,18 @@
 	return false;
 }
 
+function resetForm() {
+	//reset form
+	//don't show elements of dataset feed
+	$("#representation_select").css("display","none");
+	$("#representation_info").css("display","none");
+	//change size of outer fieldset
+	$("#client").css("height","400px");
+}
+
+
 function showDatasetList(featureCollection) {
+	resetForm();
 	if (featureCollection == null) {
 		alert("No parseable content found");
 		return false;
@@ -150,6 +159,7 @@
     		var $this = $(this);
 		method =  "getDatasetFeedObjectFromUrl";
         	data = $this.val();
+		resetForm();
 		callServer(data,method);
 	});
 	method =  "getDatasetFeedObjectFromUrl";
@@ -174,15 +184,17 @@
 	var selectROptions = "";
 	//iterate over all possible representations, which are modeled as entries in the dataset feed (here features of the featureCollection)
 	for(var i=0; i<featureCollection.features.length; ++i) {
-		selectROptions = selectROptions+"<option value='"+featureCollection.features[i].properties.datasetFeedLink+"' url='"+featureCollection.features[i].properties.datasetFeedLink+"'>"+featureCollection.features[i].properties.title+"</option>";
+		selectROptions = selectROptions+"<option value='"+i+"' url='"+featureCollection.features[i].properties.datasetFeedLink+"'>"+featureCollection.features[i].properties.title+"</option>";
 	}
 	datasetEntrySelect.append(selectROptions);
 	fillSectionList(featureCollection, id);
+	//alert(id);
 	$('#dataset_representation_select').bind('change', function() {
-    		//var $this = $(this);
+    		var $this = $(this);
 		//method =  "getDatasetLinkFromUrl";
-        	//data = $this.val(); TODO
-		alert("list changed");
+        	//data = $this.val();
+		//alert($this.val());
+		fillSectionList(featureCollection,$this.val());
 		//callServer(data,method);
 	});
 }
@@ -190,14 +202,36 @@
 function fillSectionList(featureCollection, k) {
 		bboxFiles.removeAllFeatures();
 		$('#section_option').remove();
-		//delete old entries
-		//datasetFileSelect =  $(document.createElement('select')).appendTo('#section_select');
-		//datasetFileSelect.attr({'id':'section_file_list'});
-		//datasetFileSelect.attr({'multiple':'multiple'});
 		//initialize option string
 		var selectFOptions = "";
-                for (var i = 0; i < featureCollection.features[k].properties.entry[k].link.length; i++) {
-                	ext = featureCollection.features[k].properties.entry[k].link[i]['@attributes'].bbox;
+		//count number of links in representation
+		var numberOfLinks = featureCollection.features[0].properties.entry[k].link.length;
+		//alert("number of links: "+numberOfLinks);
+		if (numberOfLinks > 1) {
+			//show list 
+			$("#representation_select").css("display","block");
+			//deactivate mapframe2 by default
+			$("#mapframe_file_list").css("display","none");
+			//$("#multi_select").css("display","none");
+			$("#representation_info").css("display","block");
+			//extent size of outer fieldset
+			$("#client").css("height","730px");
+			//test if the bbox attribute of the first link is set
+		        if (featureCollection.features[0].properties.entry[k].link[0]['@attributes'].bbox != '') {
+				//show mapframe
+				$("#mapframe_file_list").css("display","block");
+				//extent size of outer fieldset
+				$("#client").css("height","900px");
+			}
+		} else {
+			/*if (numberOfLinks == 1) {
+				//open single link for download!
+				//show download symbol
+				
+			}*/
+		}
+                for (var i = 0; i < featureCollection.features[0].properties.entry[k].link.length; i++) {
+                	ext = featureCollection.features[0].properties.entry[k].link[i]['@attributes'].bbox;
 			extArrayNew = new Array();
 			extArray = ext.split(",");
 			//sort array to lat lon
@@ -206,10 +240,10 @@
 			extArrayNew[2] = extArray[3];
 			extArrayNew[3] = extArray[2];
                 	bound = OpenLayers.Bounds.fromArray(extArrayNew);
-			attributes = {id: i, url:featureCollection.features[k].properties.entry[k].link[i]['@attributes'].href};
+			attributes = {id: i, url:featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href};
                 	box = new OpenLayers.Feature.Vector(bound.toGeometry(),attributes);
                 	bboxFiles.addFeatures(box);
-			selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].href+"' title='"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].title+"' onclick='highlightFeatureIndexById("+i+");'>"+featureCollection.features[k].properties.entry[k].link[i]['@attributes'].title+"</option>";	
+			selectFOptions = selectFOptions+"<option value='"+i+"' url='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].href+"' title='"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"' onclick='highlightFeatureIndexById("+i+",true);' onmouseover='highlightFeatureIndexById("+i+",false);'>"+featureCollection.features[0].properties.entry[k].link[i]['@attributes'].title+"</option>";	
                	}
 		//count features of bboxFiles
 		//bboxFiles if not available show error message
@@ -228,7 +262,7 @@
 				var url = feature.attributes.url;
 				$('#section_option option').removeAttr('selected')
 				$("#section_option option[value='"+id+"']").attr('selected',true);
-				window.open(url,'download_window');
+				//window.open(url,'download_window');
 
 				/*if ($('#multi_select').is(':checked')) {
 					alert("checked");
@@ -266,7 +300,7 @@
 	}
 }
 
-function highlightFeatureIndexById(id) {
+function highlightFeatureIndexById(id, open) {
 	features = bboxFiles.features;
 	for(var i=0; i<features.length; ++i) {
 		if(features[i].attributes.id == id) {
@@ -277,10 +311,11 @@
 	//unselect all if one is selected 
 	sf.unselectAll();
 	sf.select(bboxFiles.features[index]);
-	window.open(bboxFiles.features[index].attributes.url,'download_window');
+	if (open) {
+		window.open(bboxFiles.features[index].attributes.url,'download_window');
+	}
 }
 
 
 
-
 		

Modified: trunk/mapbender/http/plugins/mb_downloadFeedClient.php
===================================================================
--- trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2012-08-20 13:41:19 UTC (rev 8462)
+++ trunk/mapbender/http/plugins/mb_downloadFeedClient.php	2012-08-22 06:20:01 UTC (rev 8463)
@@ -18,7 +18,7 @@
 ?>
 <html>
 <head>
-<title>INSPIRE ATOM Feed Client - Prototype</title> 
+<title><?php echo _mb("INSPIRE ATOM Feed Client");?></title> 
 <meta name="description" content="INSPIRE ATOM Feed Client" xml:lang="en" />
 <meta name="keywords" content="INSPIRE SDI GDI Download" xml:lang="en" />	
 <meta http-equiv="cache-control" content="no-cache">
@@ -111,7 +111,7 @@
 <body onload="init()">
 
 <fieldset id="client">
-	<legend><?php echo _mb("INSPIRE Download Service ATOM Feed Client - Prototype");?><!--<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Client to download INSPIRE data on an easy way.");?>'}" src="../img/questionmark.png" alt="" />--></legend>
+	<legend><?php echo _mb("INSPIRE Download Service ATOM Feed Client");?><!--<img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Client to download INSPIRE data on an easy way.");?>'}" src="../img/questionmark.png" alt="" />--></legend>
 	<div id="input_feed_url">
 	<p>    
 		<form id="service_feed_form">
@@ -120,9 +120,10 @@
 		</form>
 	</p>
 	</div>
-	<div id="dataset_select">
-		<div id="dataset_list"></div>
+	<div id="dataset_list">
+		<div id="dataset_select"></div>
 	</div>
+	<br>
 	<div id="dataset_info">
 	<!--<fieldset>
 		<legend><?php echo _mb("Select dataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Select single dataset either in list or on map");?>'}" src="../img/questionmark.png" alt="" /></legend>-->
@@ -159,12 +160,14 @@
     <div id="representation_info">
 	<!--<fieldset>
 	<legend><?php echo _mb("Files");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Files which can be downloaded");?>'}" src="../img/questionmark.png" alt="" /></legend>-->
-	<input id="multi_select" type="checkbox" disabled><?php echo _mb("Select multiple tiles");?></input><br>
-	<label for="mapframe_file_list"><?php echo _mb("Position of files (if available)");?>:</label>
+	<!--<input id="multi_select" type="checkbox" disabled ><?php echo _mb("Select multiple tiles");?></input><br>-->
+	<!--<label for="mapframe_file_list"><?php echo _mb("Position of files (if available)");?>:</label>-->
 	<!--<input type="list" id="file_list"/>-->
 	<div id="mapframe_file_list"></div>
-	<label for="section_list"><?php echo _mb("List of files");?>:</label>
-	<div id="section_list"></div>
+	<br>
+	
+	<!--<label for="section_list"><?php echo _mb("List of files");?>:</label>-->
+	<div id="section_list"><?php echo _mb("Select to download dataset");?>:<br></div>
 	<!--<select id="section_file_list" multiple='multiple'>-->
 	<!--<input type="button" title="Download selected files" value="Download selection"/>-->
 	<!--</fieldset>	-->



More information about the Mapbender_commits mailing list