diff --git a/constants.js b/constants.js index 42540c1..baa7396 100644 --- a/constants.js +++ b/constants.js @@ -1,7 +1,7 @@ 'use strict'; // Google Drive server address -const GD_SERVER_ADDRESS = 'https://script.google.com/macros/s/AKfycbwgjNyIvsT0NCp-TviTk5Tvc9i279eKE9hBWPxshoZwLCkJfd82/exec'; +const GD_SERVER_ADDRESS = 'https://script.google.com/macros/s/AKfycbwPzbOP6CMqtj4LA6EcmctOmy4IDJFsz08IwoYsxG7gysA6Ownnorzbkx3aY7AMWYqibg/exec'; // Cubic-Bezier(0.25,0.1,0.25,1) // For x in [ 0 ; 1 ] (in this case in steps of 0.01) diff --git a/main.js b/main.js index 014566c..f624b55 100644 --- a/main.js +++ b/main.js @@ -18,26 +18,24 @@ let countries; PROMISES.push(fetch(GD_SERVER_ADDRESS) .then(response => response.text()) .then(data => { - meteoriteData = d3.csvParse(data, d => { - d.year = d3.timeParse('%Y')(d.year); - d.long = parseFloat(d.long); - d.lat = parseFloat(d.lat); - d.mass = parseFloat(d.mass); - return d; - }); + meteoriteData = d3.csvParse(data, d => ({ + ...d, + year : d3.timeParse('%Y')(d.year), + long : parseFloat(d.long), + lat : parseFloat(d.lat), + mass : parseFloat(d.mass) + })); })); // Get the data grouped by year and set up the timeline PROMISES.push(fetch(GD_SERVER_ADDRESS + '?groupByYear') .then(response => response.text()) .then(data => { - const DATA_GROUPED_BY_YEAR = d3.csvParse(data, d => { - return { - year : d3.timeParse('%Y')(d.year), - number : parseInt(d.number), - totalMass : parseFloat(d.totalMass) - }; - }); + const DATA_GROUPED_BY_YEAR = d3.csvParse(data, d => ({ + year : d3.timeParse('%Y')(d.year), + number : parseInt(d.number), + totalMass : parseFloat(d.totalMass) + })); time = DATA_GROUPED_BY_YEAR[0].year.getFullYear(); setUpTimeline(DATA_GROUPED_BY_YEAR); })); diff --git a/vis/globe/camera.js b/vis/globe/camera.js index 8a92cf2..e3f2d75 100644 --- a/vis/globe/camera.js +++ b/vis/globe/camera.js @@ -102,9 +102,14 @@ function focusOnCountry(countryCode) { if (COUNTRY !== undefined) { + const maxLong = parseFloat(COUNTRY.maxLong); + const minLong = parseFloat(COUNTRY.minLong); + const maxLat = parseFloat(COUNTRY.maxLat); + const minLat = parseFloat(COUNTRY.minLat); + const R = CAMERA_BOUNDS.MIN + Math.floor(Math.max( - parseFloat(COUNTRY.maxLong) - parseFloat(COUNTRY.minLong), - parseFloat(COUNTRY.maxLat) - parseFloat(COUNTRY.minLat) + maxLong - minLong, + maxLat - minLat )); moveCameraTo( diff --git a/vis/statistics.js b/vis/statistics.js index 8c4c4be..8a70911 100644 --- a/vis/statistics.js +++ b/vis/statistics.js @@ -63,6 +63,8 @@ const BACK_BUTTON_SIZE = LEFT_PANE_DIMENSIONS.WIDTH * 0.1; const HEAVIEST_METEORITE_MESH_MIN_SCALE = 0.0001; +const ANTARCTICA_AREA = 14200000; + /* Variables */ @@ -306,7 +308,11 @@ function setUpBipartiteGraph() { dataFinal.forEach(e=>e.CountryName=(groupByCountry.filter(f=>f.country==e.country).map(f=>parseFloat(f.totalMass)/(countries.filter(d=>d.country==f.country).map(d=>parseInt(d.area))))>1) && e.country!=='_' ? countries.filter(d=>d.country===e.country).map(d=>d.name)[0]:'Others'); //Density [gr/km2] - dataFinal.forEach(e=>e.Density=parseFloat(e.mass)/(countries.filter(d=>d.country==e.country).map(d=>parseInt(d.area)))); + dataFinal.forEach(entry => { + const entryCountry = countries.find(country => country.country == entry.country); + const area = entry.country === '0' ? ANTARCTICA_AREA : parseInt(entryCountry.area); + entry.Density = parseFloat(entry.mass) / area; + }); //----------------Iron Meteorites----------------------------------------------- let ironMeteorites = dataFinal.filter(e=>e.recclass.includes('Iron') || e.recclass.includes('Relict iron'));