Changeset 306 for binary-improvements/webserver
- Timestamp:
- Aug 2, 2017, 6:46:15 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
binary-improvements/webserver/js/map.js
r253 r306 93 93 }); 94 94 95 var densityMismatchMarkerGroupAir = L.markerClusterGroup({ 96 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 97 }); 98 var densityMismatchMarkerGroupTerrain = L.markerClusterGroup({ 99 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 100 }); 101 var densityMismatchMarkerGroupNonTerrain = L.markerClusterGroup({ 102 maxClusterRadius: function(zoom) { return zoom == mapinfo.maxzoom ? 10 : 50; } 103 }); 104 95 105 96 106 var layerControl = L.control.layers({ … … 117 127 118 128 layerControl.addOverlay (GetRegionLayer (mapinfo), "Region files"); 129 layerCount++; 119 130 120 131 var miniMap = new L.Control.MiniMap(tileLayerMiniMap, { … … 166 177 layerCount++; 167 178 } 168 179 169 180 if (layerCount > 0) { 170 181 layerControl.addTo(map); … … 430 441 } 431 442 443 444 445 446 447 448 449 450 451 // =============================================================================================== 452 // Density markers 453 454 var setDensityMarkers = function(data) { 455 var densityCountAir = 0; 456 var densityCountTerrain = 0; 457 var densityCountNonTerrain = 0; 458 459 densityMismatchMarkerGroupAir.clearLayers(); 460 densityMismatchMarkerGroupTerrain.clearLayers(); 461 densityMismatchMarkerGroupNonTerrain.clearLayers(); 462 463 464 var downloadCsv = true; 465 var downloadJson = false; 466 467 if (downloadJson) { 468 var jsonAir = []; 469 var jsonTerrain = []; 470 var jsonNonTerrain = []; 471 } 472 if (downloadCsv) { 473 var csvAir = "x;y;z;Density;IsTerrain;BvType\r\n"; 474 var csvTerrain = "x;y;z;Density;IsTerrain;BvType\r\n"; 475 var csvNonTerrain = "x;y;z;Density;IsTerrain;BvType\r\n"; 476 } 477 478 $.each( data, function( key, val ) { 479 if (val.bvtype == 0) { 480 marker = L.marker([val.x, val.z]).bindPopup( 481 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 482 ); 483 densityMismatchMarkerGroupAir.addLayer(marker); 484 densityCountAir++; 485 if (downloadJson) { 486 jsonAir.push (val); 487 } 488 if (downloadCsv) { 489 csvAir += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 490 } 491 } else if (val.terrain) { 492 marker = L.marker([val.x, val.z]).bindPopup( 493 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 494 ); 495 densityMismatchMarkerGroupTerrain.addLayer(marker); 496 densityCountTerrain++; 497 if (downloadJson) { 498 jsonTerrain.push (val); 499 } 500 if (downloadCsv) { 501 csvTerrain += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 502 } 503 } else { 504 marker = L.marker([val.x, val.z]).bindPopup( 505 "Density Mismatch: <br>Position: " + val.x + " " + val.y + " " + val.z + "<br>Density: " + val.density + "<br>isTerrain: " + val.terrain + "<br>bv.type: " + val.bvtype 506 ); 507 densityMismatchMarkerGroupNonTerrain.addLayer(marker); 508 densityCountNonTerrain++; 509 if (downloadJson) { 510 jsonNonTerrain.push (val); 511 } 512 if (downloadCsv) { 513 csvNonTerrain += val.x + ";" + val.y + ";" + val.z + ";" + val.density + ";" + val.terrain + ";" + val.bvtype + "\r\n"; 514 } 515 } 516 }); 517 518 layerControl.addOverlay (densityMismatchMarkerGroupAir, "Density Mismatches Air (<span id='mapControlDensityCountAir'>0</span>)"); 519 layerControl.addOverlay (densityMismatchMarkerGroupTerrain, "Density Mismatches Terrain (<span id='mapControlDensityCountTerrain'>0</span>)"); 520 layerControl.addOverlay (densityMismatchMarkerGroupNonTerrain, "Density Mismatches NonTerrain (<span id='mapControlDensityCountNonTerrain'>0</span>)"); 521 522 $( "#mapControlDensityCountAir" ).text( densityCountAir ); 523 $( "#mapControlDensityCountTerrain" ).text( densityCountTerrain ); 524 $( "#mapControlDensityCountNonTerrain" ).text( densityCountNonTerrain ); 525 526 if (downloadJson) { 527 download ("air-negative-density.json", JSON.stringify(jsonAir, null, '\t')); 528 download ("terrain-positive-density.json", JSON.stringify(jsonTerrain, null, '\t')); 529 download ("nonterrain-negative-density.json", JSON.stringify(jsonNonTerrain, null, '\t')); 530 } 531 if (downloadCsv) { 532 download ("air-negative-density.csv", csvAir); 533 download ("terrain-positive-density.csv", csvTerrain); 534 download ("nonterrain-negative-density.csv", csvNonTerrain); 535 } 536 537 function download(filename, text) { 538 var element = document.createElement('a'); 539 var file = new Blob([text], {type: 'text/plain'}); 540 element.href = URL.createObjectURL(file); 541 element.download = filename; 542 543 element.style.display = 'none'; 544 document.body.appendChild(element); 545 546 element.click(); 547 548 document.body.removeChild(element); 549 } 550 } 551 552 $.getJSON("densitymismatch.json") 553 .done(setDensityMarkers) 554 .fail(function(jqxhr, textStatus, error) { 555 console.log("Error fetching density mismatch list"); 556 }); 557 432 558 } 433 559
Note:
See TracChangeset
for help on using the changeset viewer.