Skip to content

Commit

Permalink
Quick fix after the app broke mysteriously
Browse files Browse the repository at this point in the history
  • Loading branch information
raja-s committed Jun 11, 2024
1 parent 33b207a commit df2e0ea
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion constants.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
26 changes: 12 additions & 14 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}));
Expand Down
9 changes: 7 additions & 2 deletions vis/globe/camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion vis/statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit df2e0ea

Please sign in to comment.