-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeaLevelData.js
More file actions
39 lines (37 loc) · 1.41 KB
/
SeaLevelData.js
File metadata and controls
39 lines (37 loc) · 1.41 KB
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
/**
* Processes and extracts sea level rise data from the CSV file and stores it as CountryPin class as an array.
*/
class SeaLevelData {
/**
* Extracts relevant information and stores it as an array of CountryPin objects.
*
* @param {object} csvTable - The csv file containing sea level rise data for different countries.
*
* @returns {SeaLevelData} A new instance of the SeaLevelData class.
*/
constructor(csvTable) {
this.countries = [];
//iterates through each row of the csv file
for (let i = 0; i < csvTable.getRowCount(); i++) {
let row = csvTable.getRow(i);
//creates a new CountryPin object for each country in the list
let country = new CountryPin(
row.get("name"), //country name
parseFloat(row.get("lat")),
parseFloat(row.get("lon")),
parseFloat(row.get("seaLevelRise")) //sea level rise from 1993-2023
);
this.countries.push(country); //adds the newly created CountryPin objects to the array
}
}
/**
* Retrieves the list of country pins with sea level data.
*
* @returns {Array} An array of CountryPin objects representing countries affected by sea level rise.
*/
getCountries() {
return this.countries;
}
}
//makes the class globally accessible
window.SeaLevelData = SeaLevelData;