diff --git a/app/__pycache__/mapController.cpython-313.pyc b/app/__pycache__/mapController.cpython-313.pyc index 709bb5a..57e6f3a 100644 Binary files a/app/__pycache__/mapController.cpython-313.pyc and b/app/__pycache__/mapController.cpython-313.pyc differ diff --git a/app/__pycache__/routes.cpython-313.pyc b/app/__pycache__/routes.cpython-313.pyc index de3ff57..7a257cf 100644 Binary files a/app/__pycache__/routes.cpython-313.pyc and b/app/__pycache__/routes.cpython-313.pyc differ diff --git a/app/mapController.py b/app/mapController.py index f15711c..28e7537 100644 --- a/app/mapController.py +++ b/app/mapController.py @@ -93,33 +93,46 @@ def fetch_geojson(conn, level, parent_code=None): ) AS path FROM wil_provinsi """ - cur.execute(old_sql) + + sql = """ + SELECT + wp.id, + wp.kode, + wp.nama, + lat, + lng, + path, + pip.persen as idx + FROM wil_provinsi wp + JOIN vw_persentase_indeks_provinsi pip on pip.kode = wp.kode + WHERE lower(pip.status) in ('maju','mandiri') + """ + cur.execute(sql) elif level == 'kabupaten': - cur.execute(""" SELECT id, kode, nama,lat,lng, - CONCAT( - REPEAT('[', 4 - (LENGTH(path) - LENGTH(REPLACE(path, '[', '')))), - path, - REPEAT(']', 4 - (LENGTH(path) - LENGTH(REPLACE(path, ']', '')))) - ) AS path - FROM wil_kabupatenkota WHERE provinsi_id = %s""", (parent_code,)) + cur.execute(""" SELECT wk.id, wk.kode, wk.nama,lat,wk.lng,wk.path, pik.persen_per_status as idx + FROM wil_kabupatenkota wk + JOIN vw_persentase_indeks_kabkota pik on pik.kode = wk.kode + WHERE provinsi_id = %s + """, (parent_code,)) elif level == 'kecamatan': cur.execute(""" - SELECT id, kode, nama,lat,lng, - CONCAT( - REPEAT('[', 4 - (LENGTH(path) - LENGTH(REPLACE(path, '[', '')))), - path, - REPEAT(']', 4 - (LENGTH(path) - LENGTH(REPLACE(path, ']', '')))) - ) AS path - FROM wil_kecamatan WHERE kabupatenkota_id = %s""", (parent_code,)) + SELECT wkc.id, wkc.kode, wkc.nama,wkc.lat,wkc.lng,wkc.path , pic.persen as idx + FROM wil_kecamatan wkc + JOIN vw_persentase_indeks_kecamatan as pic on pic.id = wkc.id + WHERE kabupatenkota_id = %s""", (parent_code,)) elif level == 'desa': cur.execute(""" - SELECT id, kode, nama, null as lat, null as lng, - CONCAT( - REPEAT('[', 4 - (LENGTH(path) - LENGTH(REPLACE(path, '[', '')))), - path, - REPEAT(']', 4 - (LENGTH(path) - LENGTH(REPLACE(path, ']', '')))) - ) AS path - FROM wil_desa WHERE kecamatan_id = %s""", (parent_code,)) + SELECT wd.id, wd.kode, wd.nama, wd.lat, wd.lng,wd.path, + CASE + WHEN lower(mid.status) = 'mandiri' THEN 100 + WHEN lower(mid.status) = 'maju' THEN 70 + WHEN lower(mid.status) = 'berkembang' THEN 50 + WHEN lower(mid.status) = 'tertinggal' THEN 20 + WHEN lower(mid.status) = 'sangat tertinggal' THEN 0 + END as idx + FROM wil_desa wd + JOIN metrik_indeks_desa mid on mid.kode_desa = wd.kode_int + WHERE kecamatan_id = %s""", (parent_code,)) else: return {"type": "FeatureCollection", "features": []} features = [] @@ -153,7 +166,8 @@ def fetch_geojson(conn, level, parent_code=None): "kode": row[1], "nama": row[2], "lat": row[3], - "lng": row[4] + "lng": row[4], + "idx": row[6] } } features.append(feature) diff --git a/app/routes.py b/app/routes.py index d092db8..522a7eb 100644 --- a/app/routes.py +++ b/app/routes.py @@ -48,6 +48,13 @@ def index(): print(data) return render_template('index.html', provinsis=data) +@main.route('/map') +def map(): + with get_connection() as conn: + data = apiController.provinsi(conn) + print(data) + return render_template('map.html', provinsis=data) + @main.route("/geojson/provinsi") def get_provinsi(): with get_connection() as conn: diff --git a/static/style.css b/static/style.css index 675dfc3..34c0d08 100644 --- a/static/style.css +++ b/static/style.css @@ -288,7 +288,7 @@ header { /*max-width: 1200px; */ margin: 10px auto 0px auto; background-color:rgb(188, 188, 188); - border-radius: 30px; + border-radius: 10px; box-shadow: 3px 3px 10px rgb(188, 188, 188); padding: 0px 20px 10px 0px; } @@ -319,6 +319,8 @@ header { flex: 3; /* 3 bagian dari 4 */ background-color: lightblue; padding: 1rem; + border-radius: 10px; + box-shadow: 3px 3px 10px rgb(188, 188, 188); } .side_container { diff --git a/templates/index.html b/templates/index.html index fba7f41..e000378 100644 --- a/templates/index.html +++ b/templates/index.html @@ -176,6 +176,16 @@ +
+
+ +
+
@@ -248,7 +258,16 @@ } currentLayer = L.geoJSON(data, { - style: { color: "blue", weight: 2 }, + style: function (feature) { + return { + color: "white", + weight: 1, + //dashArray: '5, 10', + opacity: 1, + fillOpacity: 0.4, + fillColor: '#32CD32' + }; + }, onEachFeature: function (feature, layer) { let clickTimer = null; layer.on('click', async function (e) { @@ -864,6 +883,23 @@ for (var i = 0; i < 7; i++) dataArray.push(Math.round(Math.random() * 100)); return dataArray; } + + function getColorByStatus(value) { + return value > 15 ? '#006400' : // dark green + value > 12 ? '#32CD32' : // lime green + value > 10 ? '#ADFF2F' : // green-yellow + value > 8 ? '#FFFF00' : // yellow + value > 5 ? '#FFA500' : // orange + '#44704BFF'; // red + } + + function getColorByValue(val) { + return val > 200 ? '#18D814' : + val > 100 ? '#50AF1C' : + val > 60 ? '#888523' : + val > 10 ? '#C05C2B' : + '#F73232'; + } window.onload = function(){ diff --git a/templates/map.html b/templates/map.html new file mode 100644 index 0000000..2427fe8 --- /dev/null +++ b/templates/map.html @@ -0,0 +1,933 @@ + + + + Peta Wilayah + + + + + + + + + +
+ +
+
+ +
+ search-button +
+
+ + + +
+
+ +
+
+
+

Total Dana Desa

+

Total Dana Desa

+

+
+ Views +
+ +
+
+

150

+

Total Serapan

+
+ + likes +
+ +
+
+

320

+

Persentase Serapan

+
+ + comments +
+ + +
+
+ +
+
+
+
+
+
+
+ + Provinsi + +
+ +
+
+
+
+
+
+
+ + Kabupaten/Kota + +
+ +
+
+
+
+
+
+
+ + Kecamatan + +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file