Skip to content

Commit

Permalink
* storing daily number of cases
Browse files Browse the repository at this point in the history
* updated logo
  • Loading branch information
FedericoTartarini committed Sep 2, 2020
1 parent d2db339 commit e6a14e6
Show file tree
Hide file tree
Showing 11 changed files with 11,830 additions and 470 deletions.
Binary file modified public/favicon.ico
Binary file not shown.
Binary file modified public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions python/conver_images.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# create favicon
magick mosquito.png -background none -resize 128x128 -density 128x128 favicon.ico
magick icon.png -background none -resize 128x128 -density 128x128 favicon.ico

magick mosquito.png -background none -resize 192x192 -density 192x192 logo192.png
magick mosquito.png -background none -resize 512x512 -density 512x512 logo512.png
magick icon.png -background none -resize 192x192 -density 192x192 logo192.png
magick icon.png -background none -resize 512x512 -density 512x512 logo512.png

62 changes: 47 additions & 15 deletions python/download_dengue_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
from bs4 import BeautifulSoup as Soup
import datetime as dt
import requests
import zipfile
import io
Expand All @@ -12,36 +13,53 @@
data_gov = "https://data.gov.sg/dataset/dengue-clusters"

html_text = requests.get(data_gov).text
soup = Soup(html_text, 'html.parser')
soup = Soup(html_text, "html.parser")

data_id = soup.find('a', {"class": "ga-dataset-download"}).get("href")
data_id = soup.find("a", {"class": "ga-dataset-download"}).get("href")

url_data = f"https://data.gov.sg{data_id}"

r = requests.get(url_data, stream=True)
z = zipfile.ZipFile(io.BytesIO(r.content))
file = z.open("dengue-clusters-kml.kml")

soup = Soup(file.read(), 'lxml') # Parse as XML
soup = Soup(file.read(), "lxml") # Parse as XML

place_marks = soup.find_all('placemark')
place_marks = soup.find_all("placemark")

dict_to_export = {}

dir_timeline_cases = os.path.join(
os.getcwd(), "src", "Data", "timeline_cases_location.json"
)

try:
with open(dir_timeline_cases) as json_file:
timeline_cases_location = json.load(json_file)
except FileNotFoundError:
timeline_cases_location = {}

for place_mark in place_marks:

location_name = \
place_mark.find('td').string.split("(")[0].split("[")[0].split(",")[0].split("/")[
0].strip()
number_cases = int(place_mark.find('simpledata', {"name": "CASE_SIZE"}).string)
# get location name
location_name = (
place_mark.find("td")
.string.split("(")[0]
.split("[")[0]
.split(",")[0]
.split("/")[0]
.strip()
)

coordinates = place_mark.find('coordinates')
number_cases = int(place_mark.find("simpledata", {"name": "CASE_SIZE"}).string)

elements = coordinates.string.split(',0.0')
coordinates = place_mark.find("coordinates")

elements = coordinates.string.split(",0.0")

polyline = []
for e in elements[:-1]:
lon, lat = e.split(',')
lon, lat = e.split(",")
polyline.append([float(lat), float(lon)])

if number_cases < 5:
Expand All @@ -59,14 +77,28 @@
elif number_cases >= 200:
color = "#000"

dict_to_export[location_name] = {"cases": number_cases,
"coordinates": polyline,
"color": color}
dict_to_export[location_name] = {
"cases": number_cases,
"coordinates": polyline,
"color": color,
}

try:
timeline_cases_location[location_name]
except KeyError:
timeline_cases_location[location_name] = {}

date = dt.datetime.now().isoformat().split("T")[0]

timeline_cases_location[location_name][date] = number_cases

# save_dir = os.path.join(os.path.dirname(os.getcwd()), "src", "Data", "dengue_data.json")
save_dir = os.path.join(os.getcwd(), "src", "Data", "dengue_data.json")

with open(save_dir, 'w') as fp:
with open(save_dir, "w") as fp:
json.dump(dict_to_export, fp)

with open(dir_timeline_cases, "w") as fp:
json.dump(timeline_cases_location, fp)

print("data correctly downloaded")
6 changes: 3 additions & 3 deletions src/Components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { faGithub, faLinkedin } from "@fortawesome/free-brands-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
const logo = require("../Static/Icons/mosquito.png");
const logo = require("../Static/Icons/icon.png");

function Footer() {
return (
Expand All @@ -16,9 +16,9 @@ function Footer() {
{/* todo add webp image */}
<source
type="image/png"
srcSet={require("../Static/Icons/mosquito.png")}
srcSet={require("../Static/Icons/icon.png")}
/>
<img src={logo} className="w-20 mx-2" alt="Dengue Singapore" />
<img src={logo} className="w-12 mx-2" alt="Dengue Singapore" />
</picture>
<div>
<p className="text-xl">Dengue SG</p>
Expand Down
4 changes: 2 additions & 2 deletions src/Components/NavigationBar.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { Link } from "react-router-dom";

const logo = require("../Static/Icons/mosquito.png");
const logo = require("../Static/Icons/icon.png");

function NavigationBar() {
const [navbarOpen, setNavbarOpen] = React.useState(false);
Expand All @@ -10,7 +10,7 @@ function NavigationBar() {
<nav className="container mx-auto flex items-center justify-between flex-wrap p-4">
<Link to="/">
<div className="flex items-center flex-shrink-0">
<img src={logo} alt="Dengue Singapore logo" className="w-20" />
<img src={logo} alt="Dengue Singapore logo" className="w-12" />
<span className="font-semibold text-xl tracking-tight ml-3 w-40">
Dengue Singapore
</span>
Expand Down
1 change: 1 addition & 0 deletions src/Data/timeline_cases_location.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Jurong West Ave 1": {"2020-09-01": 7, "2020-09-02": 8}, "Dover Cres": {"2020-09-02": 2}, "Lor1ToaPayoh": {"2020-09-02": 69}, "Balmoral Cres": {"2020-09-02": 127}, "Aljunied Rd": {"2020-09-02": 359}, "Marine Cres": {"2020-09-02": 70}, "EatonPl": {"2020-09-02": 99}, "Woodlands Ave 4": {"2020-09-02": 6}, "Bishan St 11": {"2020-09-02": 89}, "Changi Rd": {"2020-09-02": 40}, "How Sun Dr": {"2020-09-02": 62}, "Ang Mo Kio Ave 3": {"2020-09-02": 107}, "Hougang St 92": {"2020-09-02": 3}, "Bendemeer Rd": {"2020-09-02": 4}, "Mei Chin Rd": {"2020-09-02": 114}, "Balestier Rd": {"2020-09-02": 15}, "Cambridge Rd": {"2020-09-02": 5}, "Joon Hiang Rd": {"2020-09-02": 25}, "East Coast Rd": {"2020-09-02": 10}, "Bowmont Gdns": {"2020-09-02": 56}, "Lor 3 Geylang": {"2020-09-02": 3}, "Chuan Dr": {"2020-09-02": 6}, "Duchess Ave": {"2020-09-02": 2}, "Segar Rd": {"2020-09-02": 6}, "Woodlands Ave 6": {"2020-09-02": 8}, "Bunga Rampai Pl": {"2020-09-02": 29}, "Kwong Ave": {"2020-09-02": 35}, "Boon Lay Dr": {"2020-09-02": 3}, "Woodlands St 13": {"2020-09-02": 5}, "DorsetRd": {"2020-09-02": 58}, "Jurong West St 93": {"2020-09-02": 2}, "Bedok Nth Ave 1": {"2020-09-02": 166}, "Clementi Ave 1": {"2020-09-02": 3}, "North Coast Ave": {"2020-09-02": 6}, "Eng Kong Pl": {"2020-09-02": 6}, "Cheng Soon Gdn": {"2020-09-02": 47}, "Choa Chu Kang Ave 2": {"2020-09-02": 4}, "Buangkok Green": {"2020-09-02": 33}, "Yishun St 81": {"2020-09-02": 24}, "Woodlands Dr 40": {"2020-09-02": 58}, "Ang Mo Kio Ave 2": {"2020-09-02": 206}, "Ang Mo Kio Ave 5": {"2020-09-02": 4}, "Jln Kayu": {"2020-09-02": 14}, "Lor 1 Toa Payoh": {"2020-09-02": 4}, "Brighton Cres": {"2020-09-02": 2}, "Flanders Sq": {"2020-09-02": 50}, "Jln Novena": {"2020-09-02": 3}, "Kew Ave": {"2020-09-02": 38}, "Bt Batok St 21": {"2020-09-02": 4}, "Bt Batok Ctrl": {"2020-09-02": 96}, "Bt Batok St 34": {"2020-09-02": 2}, "Tampines St 23": {"2020-09-02": 52}, "Yishun Ring Rd": {"2020-09-02": 2}, "Elliot Rd": {"2020-09-02": 94}, "Prinsep Lk": {"2020-09-02": 6}, "Balmoral Pk": {"2020-09-02": 8}, "Bangkit Rd": {"2020-09-02": 16}, "Havelock Rd": {"2020-09-02": 15}, "Leicester Rd": {"2020-09-02": 203}, "Carpmael Rd": {"2020-09-02": 8}, "Jln Chengkek": {"2020-09-02": 8}, "Chuan Hoe Ave": {"2020-09-02": 46}, "Pk Villas Rise": {"2020-09-02": 16}, "Jurong West St 64": {"2020-09-02": 3}, "Jurong East St 21": {"2020-09-02": 2}, "Faber Gr": {"2020-09-02": 3}, "Jurong West Ave 42": {"2020-09-02": 3}, "Choa Chu Kang Ave 3": {"2020-09-02": 2}, "Hougang St 61": {"2020-09-02": 2}, "Cavenagh Rd": {"2020-09-02": 3}, "Dalvey Estate": {"2020-09-02": 4}, "Sims Dr": {"2020-09-02": 2}, "Fernhill Cres": {"2020-09-02": 4}, "Woodlands Circle": {"2020-09-02": 19}, "Kent Rd": {"2020-09-02": 16}, "Hougang Ave 8": {"2020-09-02": 6}, "Defu Ln 8": {"2020-09-02": 2}, "Parry Ave": {"2020-09-02": 3}, "Hougang Ave 3": {"2020-09-02": 19}, "Tampines Ave 4": {"2020-09-02": 2}, "Queen St": {"2020-09-02": 16}, "BirchRd": {"2020-09-02": 88}, "Seletar Nth Lk": {"2020-09-02": 2}, "Bedok South Ave 1": {"2020-09-02": 39}, "Jln Arnap": {"2020-09-02": 3}, "Pasir Ris St 71": {"2020-09-02": 31}, "Tampines St 21": {"2020-09-02": 15}, "Hougang Ave 6": {"2020-09-02": 5}, "Hougang Ave 2": {"2020-09-02": 22}, "Geylang Bahru": {"2020-09-02": 30}, "Lor 4 Toa Payoh": {"2020-09-02": 71}, "Jln Pelatina": {"2020-09-02": 2}, "Hougang St 52": {"2020-09-02": 4}, "DeskerRd": {"2020-09-02": 160}, "Ang Mo Kio Ave 4": {"2020-09-02": 85}, "Hougang Ave 1": {"2020-09-02": 26}, "Jurong East St 13": {"2020-09-02": 3}, "Yishun Ave 11": {"2020-09-02": 4}, "Cheng Soon Cres": {"2020-09-02": 73}, "Woodlands Dr 62": {"2020-09-02": 2}, "Woodlands St 41": {"2020-09-02": 2}, "Woodlands St 81": {"2020-09-02": 2}, "Bedok Reservoir Rd": {"2020-09-02": 3}, "Rivervale Dr": {"2020-09-02": 2}, "Compassvale Walk": {"2020-09-02": 16}, "Pasir Ris St 11": {"2020-09-02": 2}, "Bt Batok St 23": {"2020-09-02": 6}, "Lor 1 Realty Rk": {"2020-09-02": 3}, "Cheviot Hill": {"2020-09-02": 10}, "Lor H Telok Kurau": {"2020-09-02": 4}, "Tampines St 22": {"2020-09-02": 3}, "Compassvale Cres": {"2020-09-02": 4}, "Edgedale Plains": {"2020-09-02": 2}, "Lim Tua Tow Rd": {"2020-09-02": 2}, "Bt Panjang Ring Rd": {"2020-09-02": 6}, "Kaki Bt Ind Ter": {"2020-09-02": 157}, "Geylang East Ave 1": {"2020-09-02": 246}, "Haig Ave": {"2020-09-02": 41}, "Delta Ave": {"2020-09-02": 14}, "Margaret Dr": {"2020-09-02": 70}, "Commonwealth Dr": {"2020-09-02": 20}, "Da Silva Ln": {"2020-09-02": 66}, "Chancery Hill Rd": {"2020-09-02": 7}, "Jln Tenggiri": {"2020-09-02": 4}, "Ubi Ave 1": {"2020-09-02": 31}, "Chai Chee Ave": {"2020-09-02": 35}, "Sims Ave": {"2020-09-02": 3}, "Pasir Ris Dr 6": {"2020-09-02": 28}, "ArnasalamChettyRd": {"2020-09-02": 331}, "Dawson Rd": {"2020-09-02": 22}, "Hougang Ave 4": {"2020-09-02": 34}, "Lucky Cres": {"2020-09-02": 99}, "Woodlands Dr 42": {"2020-09-02": 7}, "Cashew Rd": {"2020-09-02": 20}, "Woodlands Height": {"2020-09-02": 13}, "Bloxhome Dr": {"2020-09-02": 75}, "Jurong West Ave 3": {"2020-09-02": 20}, "Bt Batok East Ave 3": {"2020-09-02": 4}, "Jurong West St 74": {"2020-09-02": 8}, "Bishan St 23": {"2020-09-02": 5}, "Jln Gelenggang": {"2020-09-02": 5}, "West Coast Cres": {"2020-09-02": 2}, "Clementi Ave 3": {"2020-09-02": 2}, "Bedok Ria Cres": {"2020-09-02": 3}, "S'goon Ave 3": {"2020-09-02": 2}, "Tampines St 71": {"2020-09-02": 5}, "Boon Tiong Rd": {"2020-09-02": 5}, "Commonwealth Cres": {"2020-09-02": 2}, "Lengkok Bahru": {"2020-09-02": 6}, "Youngbery Ter": {"2020-09-02": 2}, "St George's Ln": {"2020-09-02": 2}, "Bt Batok West Ave 5": {"2020-09-02": 4}, "Ang Mo Kio Ave 1": {"2020-09-02": 21}, "Pasir Ris Ave": {"2020-09-02": 2}, "Mcnair Rd": {"2020-09-02": 41}, "Bishan St 13": {"2020-09-02": 25}, "Beach Rd": {"2020-09-02": 7}, "Woodlands Cres": {"2020-09-02": 4}, "Potong Pasir Ave 1": {"2020-09-02": 4}, "Beatty Rd": {"2020-09-02": 45}, "Queen's Rd": {"2020-09-02": 2}, "Canberra St": {"2020-09-02": 3}, "Springside Lk": {"2020-09-02": 2}, "Canberra Dr": {"2020-09-02": 2}, "Punggol Way": {"2020-09-02": 3}, "Tampines Ave 7": {"2020-09-02": 4}, "Tampines St 45": {"2020-09-02": 3}, "Tamarind Rd": {"2020-09-02": 3}, "Jln Bukit Merah": {"2020-09-02": 2}, "Simei St 4": {"2020-09-02": 4}, "Bayshore Rd": {"2020-09-02": 2}, "Bedok Nth Ave 3": {"2020-09-02": 3}, "Charlton Ln": {"2020-09-02": 37}, "Ho Ching Rd": {"2020-09-02": 7}, "Joo Chiat Ave": {"2020-09-02": 10}, "Selegie Rd": {"2020-09-02": 13}, "Jln Bahagia": {"2020-09-02": 30}, "Ah Hood Rd": {"2020-09-02": 4}, "Jurong West Ctrl 1": {"2020-09-02": 17}, "Tai Hwan Ln": {"2020-09-02": 2}, "Bedok Nth Ave 2": {"2020-09-02": 11}, "Bishan St 22": {"2020-09-02": 4}, "Tanah Merah Kechil Ave": {"2020-09-02": 5}, "Balam Rd": {"2020-09-02": 162}, "Jln Daud": {"2020-09-02": 7}, "Jln Taman": {"2020-09-02": 19}, "Tampines St 41": {"2020-09-02": 28}, "Marine Dr": {"2020-09-02": 6}, "La Salle St": {"2020-09-02": 2}, "Bedok South Rd": {"2020-09-02": 3}, "St. Patrick's Rd": {"2020-09-02": 4}, "Elite Ter": {"2020-09-02": 3}, "Woodlands Ter": {"2020-09-02": 2}, "Third Ave": {"2020-09-02": 2}, "Canberra Cres": {"2020-09-02": 2}, "Berwick Dr": {"2020-09-02": 63}, "Jln Limau Bali": {"2020-09-02": 13}, "French Rd": {"2020-09-02": 20}, "Eunos Ave 8": {"2020-09-02": 48}, "Cassia Cres": {"2020-09-02": 161}, "Elite Pk Ave": {"2020-09-02": 35}, "Butterworth Ln": {"2020-09-02": 80}, "Chiltern Dr": {"2020-09-02": 160}, "Jln Batu": {"2020-09-02": 3}, "CarpmaelRd": {"2020-09-02": 99}, "Jln Chermat": {"2020-09-02": 75}, "Bridport Ave": {"2020-09-02": 27}, "Jln Berseh": {"2020-09-02": 31}, "Woodlands Dr 50": {"2020-09-02": 79}, "Bedok Nth Ave 4": {"2020-09-02": 4}, "Coldstream Ave": {"2020-09-02": 36}, "Bt Batok West Ave 6": {"2020-09-02": 3}, "Pasir Ris Dr 10": {"2020-09-02": 17}, "S'goon Ave 4": {"2020-09-02": 6}, "Admiralty Lk": {"2020-09-02": 6}, "Woodlands Dr 16": {"2020-09-02": 13}, "Jln Jarak": {"2020-09-02": 67}, "Hougang Ctrl": {"2020-09-02": 2}, "Bt Tunggal Rd": {"2020-09-02": 16}, "Telok Blangah Cres": {"2020-09-02": 15}, "Cantonment Rd": {"2020-09-02": 2}, "Iqbal Ave": {"2020-09-02": 13}, "Kensington Pk Dr": {"2020-09-02": 123}, "Choa Chu Kang Gr": {"2020-09-02": 7}, "Riverina Cres": {"2020-09-02": 3}, "Woodlands Dr 14": {"2020-09-02": 2}, "Eunos Cres": {"2020-09-02": 34}, "Bt Timah Rd": {"2020-09-02": 5}, "Admiralty Rd West": {"2020-09-02": 3}, "West Coast Rd": {"2020-09-02": 11}, "Jln Bunga Rampai": {"2020-09-02": 86}, "Adis Rd": {"2020-09-02": 132}, "Begonia Dr": {"2020-09-02": 5}, "Tampines St 12": {"2020-09-02": 3}, "Cranborne Rd": {"2020-09-02": 3}, "Fishery Port Rd": {"2020-09-02": 39}, "Bedok Nth Dr": {"2020-09-02": 6}, "Yishun St 20": {"2020-09-02": 5}, "Jurong West St 73": {"2020-09-02": 2}, "Bt Batok West Ave 2": {"2020-09-02": 6}, "Seletar Green View": {"2020-09-02": 3}, "Joo Koon Circle": {"2020-09-02": 2}, "Woodlands Ave 5": {"2020-09-02": 8}, "Jelapang Rd": {"2020-09-02": 6}, "Hemmant Rd": {"2020-09-02": 64}, "ArthurRd": {"2020-09-02": 313}, "Kim Seng Rd": {"2020-09-02": 4}, "Pasir Ris Dr 4": {"2020-09-02": 6}, "Jln Chegar": {"2020-09-02": 12}, "East Coast Ter": {"2020-09-02": 6}, "Marine Parade Rd": {"2020-09-02": 3}, "Ang Mo Kio Ave 10": {"2020-09-02": 2}, "Cres Rd": {"2020-09-02": 7}, "Alexandra Rd": {"2020-09-02": 9}, "Jurong East St 24": {"2020-09-02": 3}, "Lor Pisang Asam": {"2020-09-02": 10}, "Holt Rd": {"2020-09-02": 2}, "Shunfu Rd": {"2020-09-02": 2}, "Jln Bt Merah": {"2020-09-02": 9}, "Kee Choe Ave": {"2020-09-02": 5}, "Clarence Ln": {"2020-09-02": 10}, "Jurong West St 62": {"2020-09-02": 10}, "Dunbar Walk": {"2020-09-02": 13}, "Ah Soo Gdn": {"2020-09-02": 68}, "West Coast Dr": {"2020-09-02": 3}, "Jurong West Ave 5": {"2020-09-02": 7}, "West Coast Ave": {"2020-09-02": 2}, "Jurong West St 81": {"2020-09-02": 2}, "Rivervale Cres": {"2020-09-02": 38}, "Ang Mo Kio Ave 9": {"2020-09-02": 2}, "Compassvale Ln": {"2020-09-02": 4}, "Aroozoo Ave": {"2020-09-02": 36}, "Clemenceau Ave Nth": {"2020-09-02": 2}, "Mimosa Dr": {"2020-09-02": 3}, "Chancery Hill Walk": {"2020-09-02": 3}, "Woodlands Ave 1": {"2020-09-02": 3}, "Yishun Ave 5": {"2020-09-02": 4}, "Yishun St 44": {"2020-09-02": 2}, "AngMoKio Ave3": {"2020-09-02": 132}, "Bishan St 12": {"2020-09-02": 38}, "KengLeeRd": {"2020-09-02": 47}, "Tanglin Halt Rd": {"2020-09-02": 44}, "Binchang Rise": {"2020-09-02": 31}, "Senja Rd": {"2020-09-02": 6}, "Fernwood Ter": {"2020-09-02": 27}, "Race Course Rd": {"2020-09-02": 5}, "Florissa Pk": {"2020-09-02": 105}, "Bedok Ctrl": {"2020-09-02": 5}, "Chancery Ln": {"2020-09-02": 15}, "Kim Keat Ave": {"2020-09-02": 4}, "Jln Angin Laut": {"2020-09-02": 2}, "Happy Ave Ctrl": {"2020-09-02": 7}, "Bedok Nth St 2": {"2020-09-02": 2}, "Angklong Ln": {"2020-09-02": 2}, "Upp S'goon View": {"2020-09-02": 2}, "Tampines St 32": {"2020-09-02": 3}, "Tampines Ave 8": {"2020-09-02": 4}, "Punggol Dr": {"2020-09-02": 3}, "Jln Lapang": {"2020-09-02": 2}, "S'goon Ave 2": {"2020-09-02": 2}, "Tuas South Ave 1": {"2020-09-02": 2}, "Moonstone Ln": {"2020-09-02": 3}, "Henderson Rd": {"2020-09-02": 2}, "Butterfly Ave": {"2020-09-02": 3}, "Anchorvale Cres": {"2020-09-02": 2}, "Bt Merah View": {"2020-09-02": 3}, "Hougang St 11": {"2020-09-02": 22}}
Binary file added src/Static/Icons/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e6a14e6

Please sign in to comment.