analytics_4877.html 16.8 KB
Benjamin Herfort committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536

<head>
 
 
 <title>GIScience MapSwipe</title>
 <link href="http://www2.geog.uni-heidelberg.de/media/favicon.ico?v=2" rel="shortcut icon">
 
 <style>
.loader {
  z-index: 9998;
  -webkit-animation: spin 2s linear infinite;
  animation: spin 2s linear infinite;
}

@-webkit-keyframes spin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
</style>
 
 <script src="js/jquery.min.js"></script>
 <link rel="stylesheet" href="css/leaflet.css" />
 <script src="js/leaflet.js"></script>
 <script src="js/leaflet.ajax.js"></script>
 <script src="js/bing.min.js"></script>
 <script src="js/L.TileLayer.BetterWMS.js"></script>

 <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
 <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
 <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
 


<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="js/c3.min.js"></script>
<link href="css/c3.css" rel="stylesheet" type="text/css">

<script>

	// Geoserver Params
	url = 'http://mapswipe.geog.uni-heidelberg.de:8080/geoserver/'
	ProjectID = '2644'
	//var ProjectID = 4877

	$(document).ready(function(){
    $('[data-toggle="tooltip"]').tooltip();   
});
	
function download_data(){

	d_layer = document.getElementById("d_layer").value
	d_datatype = document.getElementById("d_datatype").value
	//console.log(d_layer)
	//console.log(d_datatype)

	if (d_layer == 'MapSwipe Groups') {
		layername = 'group_geom'
	}
	if (d_layer == 'Yes') {
		layername = 'result_yes'
	}
	if (d_layer == 'Maybe') {
		layername = 'result_maybe'
	}
	if (d_layer == 'Bad') {
		layername = 'result_badimage'
	}
	
	if (d_datatype == 'KML') {
		download_url = url + 'cite/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:'+layername+'&outputFormat=kml'
	};
	if (d_datatype == 'GeoJSON'){
		download_url = url + 'cite/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:'+layername+'&outputFormat=application%2Fjson'
	};
	if (d_datatype == 'Shapefile') {
		download_url = url + 'cite/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=cite:'+layername+'&outputFormat=shape-zip'
	}
	
	console.log(download_url)
	window.open(download_url)

}



function get_bounds(geo_layer, callback){
	//console.log(geo_layer);
	geo_bounds = geo_layer.getBounds();
	//console.log(geo_bounds)
	callback && callback(geo_bounds);
}


function getHOTdata(hot_project_id){
	
	url = 'http://tasks.hotosm.org/project/{task_id}/tasks.json'
	url = url.replace('{task_id}',hot_project_id);
	console.log(url);
	
	var jsonTest2 = new L.GeoJSON.AJAX(url,{
	style: function(feature) {
        switch (feature.properties.state) {
			case 0: return {color: "gray", weight: 1, opacity: 0.7, fillColor: "#dfdfdf", fillOpacity: 0.4 };
			case 1: return {color: "gray", weight: 1, opacity: 0.7, fillColor: "gray", fillOpacity: 0.4 };
            case 2:   return {color: "gray", weight: 1, opacity: 0.7, fillColor: "orange", fillOpacity: 0.4 };
            case 3:   return {color: "gray", weight: 1, opacity: 0.7, fillColor: "green", fillOpacity: 0.4};
            case -1:   return {color: "gray", weight: 1, opacity: 0, fillColor: "#dfdfdf", fillOpacity: 0};
			}}});
	return jsonTest2
}

function search() {
	var task_id = document.getElementById('project_id').value;
	document.getElementById('loader').style.display = 'Block';
	project_ids = task_id.split(',')
	project_ids.forEach(function(entry) {
			geojson_layer = getHOTdata(entry)
			feature_group.addLayer(geojson_layer)
			map.addLayer(geojson_layer)
			//console.log(geojson_layer)
		});
	window.history.pushState(null, null, '?id='+task_id)
	setTimeout(function(){document.getElementById('loader').style.display = 'None';map.fitBounds(feature_group.getBounds())},2500)
}



function getQueryVariable(variable)
{
	   var query = window.location.search.substring(1);
	   console.log(query)
       var vars = query.split("&");
       for (var i=0;i<vars.length;i++) {
               var pair = vars[i].split("=");
               if(pair[0] == variable){return pair[1];}
       }
       return(false);
}


function show_map(){
    
	//
	
	progress_array = ['progress']
	mappers_array = ['mappers']
	timestamp_array = ['x']
	plot_array = []
	
	
	
	$.get( "data/stats_4877.csv", function( data ) {
		//console.log(data);
		var stats_items = data.split('\n')
		len = stats_items.length
		
		mappers = stats_items[(len-2)].split(',')[6]
		progress = stats_items[(len-2)].split(',')[1]
		yes_count = stats_items[(len-2)].split(',')[7]
		maybe_count = stats_items[(len-2)].split(',')[8]
		bad_count = stats_items[(len-2)].split(',')[9]

		for (i = 1; i < (len-1); i++) {
			mappers_array.push(stats_items[i].split(',')[6])
			progress_array.push(parseFloat(stats_items[i].split(',')[1]).toFixed(2))
			var d = new Date(1000*parseInt(stats_items[i].split(',')[0]))
			//console.log(d)
			
			//'%Y-%m-%d %H:%M'
			var date_string = d.toISOString()
			
			
			timestamp_array.push(date_string)
			plot_array.push(date_string,parseFloat(stats_items[i].split(',')[1]))
		}
		
		/*
		console.log(mappers_array)
		console.log(progress_array)
		console.log(plot_array)
		console.log(timestamp_array)
		*/
		
		// Update number of mappers
		mappers_number = Math.round(mappers/10)
		mappers_icons = ''
		for (i = 0; i < mappers_number; i++) {
			mappers_icons = mappers_icons + '<i class="fa fa-lg fa-user-circle-o" aria-hidden="true"></i> '
		}
		mappers_icons = mappers_icons +  '<span id="number_mappers">' + mappers + '</span>'
		document.getElementById('mappers_icons').innerHTML = mappers_icons
		
		// update progress
		round_progress = Math.round(progress*100)
		document.getElementById('progress').innerHTML = Math.round(round_progress)+'%'
		$('#progress_bar').attr('aria-valuenow', round_progress).css('width',round_progress+'%');

		
		// update yes count
		round_yes_count = Math.round((yes_count*0.0225)/50)
		//yes_count = Math.round(yes_count*0.0225)
		yes_icons = ''
		for (i = 0; i < round_yes_count; i++) {
			yes_icons = yes_icons + '<i class="fa fa-square" aria-hidden="true" style="color: green"></i> '
		}
		yes_icons = yes_icons +  '<span id="sqkm_green">' + yes_count + '</span>*<b>yes</b> <a onclick="map.addLayer(wms_result_yes)">Show on the map!</a></br>'
		document.getElementById('yes').innerHTML = yes_icons
		
		
		// update maybe count
		round_maybe_count = Math.round((maybe_count*0.0225)/50)
		//maybe_count = Math.round(maybe_count*0.0225)
		maybe_icons = ''
		for (i = 0; i < round_maybe_count; i++) {
			maybe_icons = maybe_icons + '<i class="fa fa-square" aria-hidden="true" style="color: yellow"></i> '
		}
		maybe_icons = maybe_icons +  '<span id="sqkm_yellow">' + maybe_count + '</span>*<b>maybe</b> <a onclick="map.addLayer(wms_result_maybe)">Show on the map!</a></br>'
		document.getElementById('maybe').innerHTML = maybe_icons
		
		// update bad count
		round_bad_count = Math.round((bad_count*0.0225)/50)
		//bad_count = Math.round(bad_count*0.0225)
		bad_icons = ''
		for (i = 0; i < round_bad_count; i++) {
			bad_icons = bad_icons + '<i class="fa fa-square" aria-hidden="true" style="color: red"></i> '
		}
		bad_icons = bad_icons +  '<span id="sqkm_red">' + bad_count + '</span>*<b>bad</b> <a onclick="map.addLayer(wms_result_bad)">Show on the map!</a></br>'
		document.getElementById('bad').innerHTML = bad_icons
		
	
		
		//console.log(stats_items[(len-2)])
	});
	
	
	//
	
	console.log("map should be shown");
	
	map = L.map('leaflet_map', {
		center: [0, 0],
		zoom: 2,
		maxZoom: 18
	});
	
	map.fitBounds([
		[9.7139196395874, 6.85936212539673],
		[8.18489074707031, 6.35032415390015]
	]);
	
	
	// http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z} 
	
	
	
	// Bing Layer
	var bing_key = 'XXXX' // Insert your Bing Key here
	var bing = L.tileLayer.bing(bing_key)
	
	map.addLayer(bing)
	
	
	
	//var osmUrl='http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
	var osmUrl='http://korona.geog.uni-heidelberg.de/tiles/roads/x={x}&y={y}&z={z}';
	var osmAttrib='Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, tiles <a href="http://www.geog.uni-heidelberg.de/gis/index_en.html">GIScience Research Group @ Heidelberg University</a>';
	var osm = new L.TileLayer(osmUrl, {attribution: osmAttrib});

	//map.addLayer(osm);

	
	//Groups
	wms_groups = L.tileLayer.betterWms(url+'cite/wms', {
		layers: 'cite:group_geom',
		transparent: true,
		format: 'image/png',
		opacity: 0.8
	})
	map.addLayer(wms_groups)
	
	//Groups
	wms_result_yes = L.tileLayer.betterWms(url+'cite/wms', {
		layers: 'cite:result_yes',
		transparent: true,
		format: 'image/png',
		opacity: 0.8
	})
	//map.addLayer(wms_result_yes)
	
		wms_result_maybe = L.tileLayer.betterWms(url+'cite/wms', {
		layers: 'cite:result_maybe',
		transparent: true,
		format: 'image/png',
		opacity: 0.8
	})
	//map.addLayer(wms_result_maybe)
	
		wms_result_bad = L.tileLayer.betterWms(url+'cite/wms', {
		layers: 'cite:result_badimage',
		transparent: true,
		format: 'image/png',
		opacity: 0.8
	})
	//map.addLayer(wms_result_bad)
	

	// Agreement
	
	
	//

	// Create and Add Layer Controls
	var baseLayers = {
		"Microsoft Bing": bing,
		"OpenStreetMap": osm
	};
	var overlays = {
		//"Settlements": Settlements,
		//"Bad Imagery": badImage,
		//"HOT Tasking Manager": HOTTasks,
		//"MapSwipe Groups": groups,
		"Progress": wms_groups,
		"Yes": wms_result_yes,
		"Maybe": wms_result_maybe,
		"Bad": wms_result_bad,
		//"Test Layer" : testLayer
		//"Raw Data": rawData
	};
	L.control.layers(baseLayers, overlays, {collapsed: false}).addTo(map);
	//
	
	var chart = c3.generate({
		bindto: '#chart',
		data: {
			x: 'x',
			xFormat: '%Y-%m-%dT%H:%M:%S.%LZ', // 'xFormat' can be used as custom format of 'x'
			columns: [
				//timestamp_array,
				//progress_array,
				//mappers_array
			],
			types: {
				progress: 'area',
				mappers: 'line'
			},
			axes: {
				progress: 'y',
				mappers: 'y2'
			}	
		},
		zoom: {
			enabled: true,
			extent: [1, 100]
		},
		axis: {
			x: {
				type: 'timeseries',
				tick: {
					//format: '%Y-%m-%d %H:%M'
					count: 3,
					format: '%Y-%m-%d %H:%M'
				}
			},
			y: {
				max: 1,
				min: 0,
				// Range includes padding, set 0 if no padding needed
				padding: {top:0, bottom:0}
			},
			y2: {
				min: 0,
				padding: {top:50, bottom:0},
				show: true
			}
		}
	});
	
	setTimeout(function () {
    chart.load({
        columns: [
            timestamp_array,
			progress_array,
			mappers_array
        ]
    });
}, 1000);
	

	
}

</script>

</head>

<body onload="show_map()">

<div class="col-md-6">

<div style="position: absolute; top: 15px; right: 20px; overflow:visible; z-index: 9997" height="70px" align="center">
<button id="searchBtn" href="#" onclick="document.getElementById('contact').style.display = 'block'" class="btn btn-primary btn">Info & Contact</button>
</div>

<h2>Project #4877 MapSwipe Nigeria for MSF 3</h2>
<p><b>requested by:</b> <span id="requester">MSF</span></b></p>


<div class="col-md-12">
<div class="col-md-6">
<img src="http://wiki.openstreetmap.org/w/images/a/ac/MSF158153_Small.jpg" width="100%">


<h3>Description:</h3>
<p><span id="description">Swipe slowly through the satellite imagery and mark anything that looks like it could be a house, village or hut. Niger State is an extremely vulnerable area of Nigeria and the data you contribute will help the MSF emergency response unit better respond to health needs in the area.</span></p>
<p><i class="fa fa-question-circle" data-toggle="tooltip" title="MapSwipe is a mobile app developed for the Missing Maps Project to enable fast satellite image classification on mobile devices." aria-hidden="true"></i><span> What is MapSwipe?</span></p> <p><i class="fa fa-question-circle"  data-toggle="tooltip" title="You install the app, join a project, and swipe through satellite imagery while tapping the features you spot. The tiles you mark will become to the base layer of detailed maps drawn by other volunteers." aria-hidden="true"></i><span> How does it work?</span></p>
</div>


<div class="col-md-6">


<p></p>
<h4><i class="fa fa-question-circle" data-toggle="tooltip" title="Latest progress of the MapSwipe project" aria-hidden="true"></i> Progress:</h4>
<div class="progress">
  <div id="progress_bar" class="progress-bar progress-bar-success progress-bar-striped active" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 99%;">
   <span id="progress" style="color: black">#</span>
  </div>
</div>


<h4><i class="fa fa-question-circle" data-toggle="tooltip" title="total number of people that contributed to this project" aria-hidden="true"></i> Mappers: </h4>
<div id="mappers_icons" class="mappers">
<i class="fa fa-lg fa-user-circle-o" aria-hidden="true"></i>
</i> <span id="number_mappers">#</span>
</div>

<p> </p>



<h4><i class="fa fa-question-circle" data-toggle="tooltip" title="total number of contributions by all MapSwipe users regarding the different classes" aria-hidden="true"></i> Results: </h4>
<div id="yes">
<i class="fa fa-square" aria-hidden="true" style="color: green"></i> <span id="sqkm_green">#</span> km<sup>2</sup> yes <a onclick="alert('show on map')">Show on the map!</a></br>
</div>
<div id="maybe">
<i class="fa fa-square" aria-hidden="true" style="color: yellow"></i> <span id="sqkm_yellow">#</span> km<sup>2</sup> maybe</br>
</div>
<div id="bad">
<i class="fa fa-square" aria-hidden="true" style="color: red"></i> <span id="sqkm_red">#</span> km<sup>2</sup> bad</br>
</div>
<h4><i class="fa fa-question-circle" data-toggle="tooltip" title="see the total progress of the project and the total number of mappers evolving over time" aria-hidden="true"></i> Timeline: </h4>

<div class='chart'>
<div id='chart' style="height:250px"></div>
</div>



</div>


</div>

</div>


<div class="col-md-6">
<div id="leaflet_map" style="background-color:grey;height: calc(100vh - 55px)">
<div style="position: absolute; bottom: 15px; left: 10px; overflow:visible; z-index: 9998">
<img src="img/legende_all.png" width="80px" />
</div>

<div style="position: absolute; bottom: 25px; right: 10px; overflow:visible; z-index: 9998" height="70px">
<a href="https://mapswipe.org/" target="blank"> <img src="img/mapswipe-logo.svg" height="70px"/></a>
<a href="http://geog.uni-heidelberg.de/gis/index_en.html" target="blank"><img src="img/logo_giscience_hd_web.png" height="70px"/></a>
</div>
</div>

<div style="padding: 10px; display: Block" align="right">

<div class="input-group">
	<label for="d_layer"> Layer: </label>
	<select  style="width: 150px" id="d_layer">
		<option>MapSwipe Groups</option>
		<option>Yes</option>
		<option>Maybe</option>
		<option>Bad</option>
	</select>
	<label for="d_datatype"> Output Format: </label>
	<select  style="width: 150px" id="d_datatype">
		<option>GeoJSON</option>
		<option>KML</option>
		<option>Shapefile</option>
	</select>
	
	  <button id="Download" href="#" onclick="download_data()" class="btn btn-primary btn">Download Data</button>
</div>


</div>




<div style="padding: 15px; background: rgba(255, 255, 255, 0.95); position: fixed; top: 5%; left: 2.5%; overflow:visible; z-index: 9999; display: None; height: 90%; width: 95%" id="contact">
	<h3>Info</h3>
	<p>This website shows statistics about MapSwipe projects. You don't know MapSwipe? It's an app for your mobile device. With MapSwipe you can help us to map the most vulnerable places in the world. For more information about MapSwipe visit <a href="http://mapswipe.org/" target="blank">mapswipe.org</a> and get the latest news at the <a href="http://k1z.blog.uni-heidelberg.de/?s=MapSwipe" target="blank">GIScience News Blog</a>.
	<p>This Website was created by Marcel Reinmuth and Benjamin Herfort. Special Thanks go to Jess Cahill for the work on improving the design. </p>
	<p>Please, be aware of that this is work in progress. We are giving our best to have this service as stable as possible, nevertheless we are still experimenting a lot. Feel free to contact us, in case you have any suggestion or question.</p>
	<h3>Acknowledgements</h3>
	<p>This work has kindly been supported by the Klaus Tschira Foundation (KTS) Heidelberg in the context of establishing the Heidelberg Institute for Geoinformation Technology (HeiGIT).</p>
	<h3>Contact</h3>
	<img style="float: left;margin-right: 10px;" src="img/logo_giscience_hd_web.png" height="60px">
		Chair of GIScience<br>
		Department of Geography<br>
		Heidelberg University, Germany
		<p style="clear: both;">
			<a href="http://www.geog.uni-heidelberg.de/giscience.html" target="_blank">http://www.geog.uni-heidelberg.de/giscience.html</a>
			<br><br>
			Email:
			<br>
			herfort[at]uni-heidelberg.de
		</p>
	<button id="searchBtn" href="#" onclick="document.getElementById('contact').style.display = 'None'" class="btn btn-primary btn">Close</button>
</div>




</body>