-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate UNEP Environmental Data API #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
GYFX35
merged 1 commit into
feat/initial-project-structure
from
integrate-unep-api-13134788857640065043
Feb 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| main { | ||
| padding: 20px; | ||
| max-width: 1000px; | ||
| margin: 0 auto; | ||
| } | ||
|
|
||
| section { | ||
| margin-bottom: 40px; | ||
| padding: 20px; | ||
| background-color: #f9f9f9; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| } | ||
|
|
||
| h2 { | ||
| color: #2c3e50; | ||
| border-bottom: 2px solid #3498db; | ||
| padding-bottom: 10px; | ||
| } | ||
|
|
||
| canvas { | ||
| max-width: 100%; | ||
| height: auto; | ||
| } | ||
|
|
||
| #unep-intro { | ||
| background-color: #e8f4f8; | ||
| border-left: 5px solid #3498db; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>UNEP Data - Environment Protection</title> | ||
| <link rel="stylesheet" href="style.css"> | ||
| <link rel="stylesheet" href="unep.css"> | ||
| <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> | ||
| </head> | ||
| <body> | ||
| <header> | ||
| <h1>UN Environment Programme (UNEP) Data</h1> | ||
| <nav> | ||
| <a href="index.html">Home</a> | ||
| </nav> | ||
| </header> | ||
| <main> | ||
| <section id="unep-intro"> | ||
| <h2>UNEP and the SDGs</h2> | ||
| <p>The United Nations Environment Programme (UNEP) is the leading global authority on the environment. It is the custodian for many Sustainable Development Goal (SDG) indicators. Below is data for two key indicators custodianed by UNEP.</p> | ||
| </section> | ||
|
|
||
| <section id="recycling-data"> | ||
| <h2>National Recycling Rate (SDG 12.5.1)</h2> | ||
| <p>Proportion of municipal waste recycled (%) - Top 10 Countries</p> | ||
| <canvas id="recyclingChart"></canvas> | ||
| </section> | ||
|
|
||
| <section id="protected-areas-data"> | ||
| <h2>Protected Areas (SDG 15.1.2)</h2> | ||
| <p>Average proportion of Terrestrial Key Biodiversity Areas (KBAs) covered by protected areas (%) - Top 10 Countries</p> | ||
| <canvas id="protectedAreasChart"></canvas> | ||
| </section> | ||
| </main> | ||
| <footer> | ||
| <p>© 2025 Environment Protection Initiative</p> | ||
| </footer> | ||
| <script src="unep.js"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| fetchRecyclingData(); | ||
| fetchProtectedAreasData(); | ||
|
|
||
| function fetchRecyclingData() { | ||
| fetch('/api/unep_recycling') | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| if (data.error) { | ||
| console.error('Error fetching recycling data:', data.error); | ||
| return; | ||
| } | ||
| renderChart('recyclingChart', data, 'Recycling Rate (%)', 'rgba(75, 192, 192, 0.2)', 'rgba(75, 192, 192, 1)'); | ||
| }) | ||
| .catch(error => console.error('Error:', error)); | ||
| } | ||
|
|
||
| function fetchProtectedAreasData() { | ||
| fetch('/api/unep_protected_areas') | ||
| .then(response => response.json()) | ||
| .then(data => { | ||
| if (data.error) { | ||
| console.error('Error fetching protected areas data:', data.error); | ||
| return; | ||
| } | ||
| renderChart('protectedAreasChart', data, 'Protected Area Coverage (%)', 'rgba(153, 102, 255, 0.2)', 'rgba(153, 102, 255, 1)'); | ||
| }) | ||
| .catch(error => console.error('Error:', error)); | ||
| } | ||
|
|
||
| function renderChart(canvasId, data, label, bgColor, borderColor) { | ||
| const ctx = document.getElementById(canvasId).getContext('2d'); | ||
| const labels = data.map(item => item.country); | ||
| const values = data.map(item => item.value); | ||
|
|
||
| new Chart(ctx, { | ||
| type: 'bar', | ||
| data: { | ||
| labels: labels, | ||
| datasets: [{ | ||
| label: label, | ||
| data: values, | ||
| backgroundColor: bgColor, | ||
| borderColor: borderColor, | ||
| borderWidth: 1 | ||
| }] | ||
| }, | ||
| options: { | ||
| scales: { | ||
| y: { | ||
| beginAtZero: true, | ||
| max: 100 | ||
| } | ||
| } | ||
| } | ||
| }); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Comparison between
year(string) and storedyear(int) will raise a TypeError.yearcomes directly from the API as a string, whilelatest_data[country]['year']is stored asint(year). On subsequent iterations this makesyear > latest_data[country]['year']a string-vs-int comparison in Python 3. Convertyearonce (e.g.year_int = int(year)) and useyear_intboth in the comparison and when storing it.