WebGIS Data Jalan
+Modul pemetaan dan pengelolaan geometri polyline untuk jaringan jalan.
+-
+
- Polyline / LineString +
- Data jalan +
- Visualisasi Leaflet +
diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4a1ea29 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM php:8.2-apache + +RUN docker-php-ext-install mysqli pdo pdo_mysql + +RUN a2enmod rewrite + +COPY . /var/www/html/ + +RUN chown -R www-data:www-data /var/www/html + +EXPOSE 80 diff --git a/README_DEPLOY_COOLIFY.md b/README_DEPLOY_COOLIFY.md new file mode 100644 index 0000000..a55954c --- /dev/null +++ b/README_DEPLOY_COOLIFY.md @@ -0,0 +1,44 @@ +# Deploy Coolify - Tugas_SIG Tiara + +Repo ini dijadikan satu landing page untuk Tugas 1 sampai Tugas 4. + +## Struktur utama + +- `/` -> Landing page tugas +- `/Tugas1/` -> Tugas 1 +- `/Tugas2/` -> Tugas 2 +- `/Tugas3/` -> Tugas 3 +- `/Tugas4/` -> Tugas 4 + +## Coolify + +Buat 1 database MySQL/MariaDB dengan Initial Database: + +```text +db_poverty_mapping +``` + +Buat 1 aplikasi dari repo ini: + +```text +Build Pack: Dockerfile +Ports Exposes: 80 +``` + +Production Environment Variables: + +```env +DB_HOST=host_database_internal +DB_PORT=3306 +DB_NAME=db_poverty_mapping +DB_USER=mysql +DB_PASS=password_normal_user_database +``` + +Setelah deploy, buka: + +```text +https://URL-TUGAS/install_database.php +``` + +Jika database berhasil diimport, hapus `install_database.php` lalu redeploy. diff --git a/index.html b/index.html index 112ec7b..f669a1a 100644 --- a/index.html +++ b/index.html @@ -1,316 +1,223 @@ - - -
- - -Integrasi WebGIS Geometri Sigma & Analisis Titik Kerawanan Kemiskinan (Poverty Mapping)
- -Repositori ini dirancang khusus untuk mengonsolidasikan 4 tugas WebGIS ke dalam satu arsitektur terintegrasi. Dengan memanfaatkan satu database utama, seluruh modul kerja spasial mulai dari pengelolaan jaringan infrastruktur (jalan, persil, titik fasilitas umum) hingga penentuan zonasi Keluarga Penerima Manfaat (KPM) bantuan sosial dapat diakses secara langsung dan dinamis.
-Modul pemetaan spasial linear yang berfungsi untuk merekam, menghitung panjang secara otomatis menggunakan sistem koordinat Leaflet, serta memetakan data jaringan jalan berdasarkan klasifikasinya.
-data_jalanModul analisis area yang memetakan batas-batas persil wilayah lahan atau pemukiman warga, lengkap dengan kalkulasi luas otomatis dalam satuan meter persegi (m²).
-data_parsilModul penanda objek vital yang mengelola persebaran koordinat fasilitas umum, infrastruktur kota, serta objek-objek spasial berformat point lainnya di dalam peta interaktif.
-data_point, geometri_sigmaSistem informasi geografis tingkat lanjut untuk penanggulangan kemiskinan. Menampilkan radius bantuan rumah ibadah (buffer), status sebaran KPM, manajemen logistik bencana, serta kontrol akses 4 role pengguna.
-users, rumah_miskin, rumah_ibadah, bantuan_tersalurKumpulan tugas WebGIS dalam satu halaman utama agar mudah diakses melalui deployment Coolify.
+Halaman ini hanya untuk tugas kelas. Project UAS tetap dideploy terpisah.
+Modul pemetaan dan pengelolaan geometri polyline untuk jaringan jalan.
+Modul pemetaan wilayah, kecamatan, batas administrasi, dan data spasial berbasis GeoJSON.
+Modul layer control untuk menampilkan data point dan layer tematik pada peta.
+Modul pemetaan kemiskinan dan bantuan sosial dengan data rumah miskin, rumah ibadah, dan bantuan tersalur.
+Target koneksi: " . htmlspecialchars($host) . ":" . htmlspecialchars((string)$port) . ", database: " . htmlspecialchars($db) . ", user: " . htmlspecialchars($user) . "
"; + +$conn = new mysqli($host, $user, $pass, $db, $port); + +if ($conn->connect_error) { + die("Koneksi gagal: " . htmlspecialchars($conn->connect_error) . "
"); +} + +$sqlFile = __DIR__ . "/database.sql"; +if (!file_exists($sqlFile)) { + die("File SQL tidak ditemukan: " . htmlspecialchars($sqlFile) . "
"); +} + +$sql = file_get_contents($sqlFile); + +// Coolify normal user biasanya tidak butuh/ tidak punya izin CREATE DATABASE. +// Database sudah dibuat dari field Initial Database, jadi baris CREATE DATABASE dan USE diabaikan. +$sql = preg_replace('/CREATE\\s+DATABASE\\s+IF\\s+NOT\\s+EXISTS\\s+`?[^`\\s;]+`?.*?;/is', '', $sql); +$sql = preg_replace('/USE\\s+`?[^`\\s;]+`?\\s*;/is', '', $sql); + +// Jika dump hasil copy menjadi komentar seperti "-- 1.\nTABEL ... CREATE TABLE", +// buang label teks agar SQL tidak error. +$sql = preg_replace('/--\\s*\\d+\\.\\s*TABEL[^\\n]*\\n/is', '', $sql); +$sql = preg_replace('/\\bTABEL\\s+(PENGGUNA|RUMAH|BENCANA|DATA)[^;]*?(CREATE\\s+TABLE)/is', '$2', $sql); + +if ($conn->multi_query($sql)) { + do { + if ($result = $conn->store_result()) { + $result->free(); + } + } while ($conn->more_results() && $conn->next_result()); + + if ($conn->errno) { + echo "Ada error saat import: " . htmlspecialchars($conn->error) . "
"; + } else { + echo "Database berhasil diimport.
"; + echo "Setelah ini, hapus file install_database.php dari repo lalu redeploy.
Import gagal: " . htmlspecialchars($conn->error) . "
"; +} + +$conn->close(); +?> diff --git a/koneksi.php b/koneksi.php index 4b94fec..bff0c40 100644 --- a/koneksi.php +++ b/koneksi.php @@ -1,73 +1,56 @@ -connect_error) { - http_response_code(500); - die(json_encode([ - 'status' => 'error', - 'message' => 'Koneksi database gagal: ' . $conn->connect_error - ])); -} - -// Set Charset ke UTF-8 agar aman membaca data koordinat spasial/GeoJSON -$conn->set_charset('utf8mb4'); - - -// 2. DETEKSI LOKASI PATH RELATIF (Cerdas mencegah error No Such File / Wrong Redirect) -if (!function_exists('getRedirectPath')) { - function getRedirectPath($targetFile) { - // Ambil nama folder tempat file PHP yang sedang berjalan berada - $currentDir = basename(dirname($_SERVER['SCRIPT_FILENAME'])); - - // Jika file pengakses ada di dalam subfolder tugas (misal: tugas1_polyline, tugas2_polygon) - // atau berada di dalam folder 'includes', mundurkan path satu tingkat ke luar menggunakan '../' - if (strpos($currentDir, 'tugas') !== false || $currentDir === 'includes') { - return '../' . $targetFile; - } - return $targetFile; - } -} - - -// 3. FUNGSI OTENTIKASI GLOBAL (Bisa langsung dipanggil di semua folder tugas Anda) -if (!function_exists('cekLogin')) { - function cekLogin() { - if (session_status() === PHP_SESSION_NONE) { - session_start(); - } - // Jika belum ada session user_id, tendang paksa ke halaman login.php dengan path yang benar - if (!isset($_SESSION['user_id'])) { - $loginPath = getRedirectPath('login.php'); - header("Location: " . $loginPath); - exit; - } - } -} - -if (!function_exists('cekRole')) { - function cekRole($role_wajib) { - if (session_status() === PHP_SESSION_NONE) { - session_start(); - } - // Jika role user tidak sesuai dengan kriteria halaman, tendang ke dashboard utama - if (!isset($_SESSION['role']) || $_SESSION['role'] !== $role_wajib) { - $dashboardPath = getRedirectPath('dashboard.php?error=unauthorized'); - header("Location: " . $dashboardPath); - exit; - } - } -} \ No newline at end of file +connect_error) { + http_response_code(500); + die(json_encode([ + 'status' => 'error', + 'message' => 'Koneksi database gagal: ' . $conn->connect_error + ])); +} + +$conn->set_charset('utf8mb4'); + +function getRedirectPath($targetFile) { + $currentDir = basename(dirname($_SERVER['SCRIPT_FILENAME'])); + if (stripos($currentDir, 'Tugas') !== false || stripos($currentDir, 'tugas') !== false || $currentDir === 'includes') { + return '../' . $targetFile; + } + return $targetFile; +} + +function cekLogin() { + if (session_status() === PHP_SESSION_NONE) { + session_start(); + } + if (!isset($_SESSION['user_id'])) { + header('Location: ' . getRedirectPath('login.php')); + exit; + } +} + +function cekRole($role_wajib) { + if (session_status() === PHP_SESSION_NONE) { + session_start(); + } + if (!isset($_SESSION['role']) || $_SESSION['role'] !== $role_wajib) { + header('Location: ' . getRedirectPath('dashboard.php?error=unauthorized')); + exit; + } +} + +function bersih($str, $conn) { + return $conn->real_escape_string(htmlspecialchars(strip_tags(trim($str)))); +} +?>