diff --git a/PANDUAN_FITUR.md b/PANDUAN_FITUR.md index ff1229e..2cafb6e 100644 --- a/PANDUAN_FITUR.md +++ b/PANDUAN_FITUR.md @@ -366,14 +366,27 @@ web-gis/ ├── create_tables.php ← Init database ├── db_config.php ← Database config │ -├── api/ -│ ├── save_rumah_ibadah.php +├── rancangan_sistem/ ← API & UI untuk rumah ibadah + penduduk miskin │ ├── get_rumah_ibadah.php +│ ├── save_rumah_ibadah.php +│ ├── update_rumah_ibadah.php │ ├── delete_rumah_ibadah.php -│ ├── save_penduduk_miskin.php │ ├── get_penduduk_miskin.php +│ ├── save_penduduk_miskin.php +│ ├── update_penduduk_miskin.php │ └── delete_penduduk_miskin.php │ +├── fitur_jalan_parsel/ ← API & UI untuk jalan rusak, polyline/polygon +│ ├── get_jalan_rusak.php +│ ├── save_jalan_rusak.php +│ └── delete_jalan_rusak.php +│ +├── layer_groups_choropleth/← API & UI untuk spatial features + choropleth +│ ├── get_features.php +│ ├── save_feature.php +│ ├── update_feature.php +│ └── delete_feature.php +│ └── data/ ├── pontianak-kecamatan.geojson ← Choropleth data └── Export_Output_2.json ← Road network data diff --git a/delete_feature.php b/delete_feature.php deleted file mode 100644 index 35148d7..0000000 --- a/delete_feature.php +++ /dev/null @@ -1,36 +0,0 @@ - 'error', 'message' => 'ID fitur tidak valid']); - $conn->close(); - exit; - } - - $stmt = $conn->prepare("DELETE FROM spatial_features WHERE id = ?"); - - if (!$stmt) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $conn->error]); - $conn->close(); - exit; - } - - $stmt->bind_param("i", $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Fitur berhasil dihapus']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} - -$conn->close(); -?> \ No newline at end of file diff --git a/delete_jalan_rusak.php b/delete_jalan_rusak.php deleted file mode 100644 index 7a0e08d..0000000 --- a/delete_jalan_rusak.php +++ /dev/null @@ -1,46 +0,0 @@ - 'error', 'message' => 'ID wajib diisi']); - exit; - } - - // Ambil data gambar untuk dihapus - $stmt = $conn->prepare("SELECT gambar FROM jalan_rusak WHERE id = ?"); - $stmt->bind_param("i", $id); - $stmt->execute(); - $result = $stmt->get_result(); - $row = $result->fetch_assoc(); - - if ($row && $row['gambar'] && file_exists($row['gambar'])) { - unlink($row['gambar']); - } - - $stmt->close(); - - // Hapus record - $stmt = $conn->prepare("DELETE FROM jalan_rusak WHERE id = ?"); - $stmt->bind_param("i", $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Laporan jalan rusak berhasil dihapus']); - } else { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); - $conn->close(); - exit; -} - -http_response_code(405); -echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); -$conn->close(); -?> \ No newline at end of file diff --git a/delete_penduduk_miskin.php b/delete_penduduk_miskin.php deleted file mode 100644 index cdd0b98..0000000 --- a/delete_penduduk_miskin.php +++ /dev/null @@ -1,26 +0,0 @@ - 'error', 'message' => 'ID tidak valid']); - $conn->close(); - exit; - } - - $stmt = $conn->prepare("DELETE FROM penduduk_miskin WHERE id = ?"); - $stmt->bind_param("i", $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Data penduduk miskin dihapus']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} -$conn->close(); -?> \ No newline at end of file diff --git a/delete_rumah_ibadah.php b/delete_rumah_ibadah.php deleted file mode 100644 index 81a5a6d..0000000 --- a/delete_rumah_ibadah.php +++ /dev/null @@ -1,26 +0,0 @@ - 'error', 'message' => 'ID tidak valid']); - $conn->close(); - exit; - } - - $stmt = $conn->prepare("DELETE FROM rumah_ibadah WHERE id = ?"); - $stmt->bind_param("i", $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah dihapus']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} -$conn->close(); -?> \ No newline at end of file diff --git a/get_features.php b/get_features.php deleted file mode 100644 index c210eb8..0000000 --- a/get_features.php +++ /dev/null @@ -1,41 +0,0 @@ -query($sql); -$features = []; - -if (!$result) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); - $conn->close(); - exit; -} - -if ($result && $result->num_rows > 0) { - while($row = $result->fetch_assoc()) { - // Mendecode data JSON koordinat agar bisa langsung digunakan oleh Leaflet di frontend - $row['geometry_data'] = json_decode($row['geometry_data']); - - // Memastikan nilai_ukur dikirim sebagai angka (float/double) - $row['nilai_ukur'] = (float)$row['nilai_ukur']; - - $features[] = $row; - } -} - -// Mengirimkan data dalam format JSON -echo json_encode($features); - -// Menutup koneksi database -$conn->close(); -?> \ No newline at end of file diff --git a/get_jalan_rusak.php b/get_jalan_rusak.php deleted file mode 100644 index 8ad088a..0000000 --- a/get_jalan_rusak.php +++ /dev/null @@ -1,29 +0,0 @@ -query($sql); -$data = []; - -if (!$result) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); - $conn->close(); - exit; -} - -if ($result && $result->num_rows > 0) { - while ($row = $result->fetch_assoc()) { - $row['latitude'] = (float)$row['latitude']; - $row['longitude'] = (float)$row['longitude']; - $data[] = $row; - } -} - -echo json_encode($data); -$conn->close(); -?> diff --git a/get_penduduk_miskin.php b/get_penduduk_miskin.php deleted file mode 100644 index 0342fca..0000000 --- a/get_penduduk_miskin.php +++ /dev/null @@ -1,34 +0,0 @@ -query($sql); -$data = []; - -if (!$result) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); - $conn->close(); - exit; -} - -if ($result->num_rows > 0) { - while ($row = $result->fetch_assoc()) { - $row['latitude'] = (float)$row['latitude']; - $row['longitude'] = (float)$row['longitude']; - $row['jumlah_anggota'] = (int)$row['jumlah_anggota']; - $row['rumah_ibadah_id'] = $row['rumah_ibadah_id'] !== null ? (int)$row['rumah_ibadah_id'] : null; - $row['jarak_ke_rumah_ibadah_m'] = $row['jarak_ke_rumah_ibadah_m'] !== null ? (float)$row['jarak_ke_rumah_ibadah_m'] : null; - $row['bantuan_status'] = $row['bantuan_status'] ?: 'belum'; - $row['bantuan_catatan'] = $row['bantuan_catatan'] ?? ''; - $data[] = $row; - } -} - -echo json_encode($data); -$conn->close(); -?> \ No newline at end of file diff --git a/get_rumah_ibadah.php b/get_rumah_ibadah.php deleted file mode 100644 index 7f016d8..0000000 --- a/get_rumah_ibadah.php +++ /dev/null @@ -1,30 +0,0 @@ -query($sql); -$data = []; - -if (!$result) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Query gagal: ' . $conn->error]); - $conn->close(); - exit; -} - -if ($result->num_rows > 0) { - while ($row = $result->fetch_assoc()) { - $row['latitude'] = (float)$row['latitude']; - $row['longitude'] = (float)$row['longitude']; - $row['radius_m'] = (int)$row['radius_m']; - $data[] = $row; - } -} - -echo json_encode($data); -$conn->close(); -?> \ No newline at end of file diff --git a/index.html b/index.html index 40d1f9d..28136aa 100644 --- a/index.html +++ b/index.html @@ -2090,8 +2090,8 @@ formData.append('gambar', fileInput.files[0]); } - fetch('save_jalan_rusak.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'save_jalan_rusak.php')) + fetch('fitur_jalan_parsel/save_jalan_rusak.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'fitur_jalan_parsel/save_jalan_rusak.php')) .then(data => { if (data.status === 'success') { showMessage('✅ Laporan jalan rusak berhasil disimpan', 'bg-green-600 text-white'); @@ -2152,7 +2152,7 @@ function loadRoadDamage(force = false) { if (!force && (document.hidden || suppressAutoReload)) return; - fetch('get_jalan_rusak.php') + fetch('fitur_jalan_parsel/get_jalan_rusak.php') .then(res => { if (!res.ok) throw new Error('HTTP Error: ' + res.status); return res.text(); @@ -2367,8 +2367,8 @@ const formData = new FormData(); formData.append('id', id); - fetch('delete_jalan_rusak.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'delete_jalan_rusak.php')) + fetch('fitur_jalan_parsel/delete_jalan_rusak.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'fitur_jalan_parsel/delete_jalan_rusak.php')) .then(data => { if (data.status === 'success') { showMessage('🗑️ Laporan berhasil dihapus', 'bg-orange-600 text-white'); @@ -3065,7 +3065,7 @@ formData.append('longitude', pendingRumahIbadahCoords.lng); formData.append('radius_m', radius); - const endpoint = id ? 'update_rumah_ibadah.php' : 'save_rumah_ibadah.php'; + const endpoint = id ? 'rancangan_sistem/update_rumah_ibadah.php' : 'rancangan_sistem/save_rumah_ibadah.php'; if (id) { formData.append('id', id); } @@ -3090,8 +3090,8 @@ const formData = new FormData(); formData.append('id', id); - fetch('delete_rumah_ibadah.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'delete_rumah_ibadah.php')) + fetch('rancangan_sistem/delete_rumah_ibadah.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'rancangan_sistem/delete_rumah_ibadah.php')) .then(data => { if (data.status === 'success') { showMessage('🗑️ Rumah ibadah berhasil dihapus', 'bg-orange-600 text-white'); @@ -3134,7 +3134,7 @@ formData.append('rumah_ibadah_nama', nearest.record.nama); formData.append('jarak_ke_rumah_ibadah_m', nearest.distance.toFixed(2)); - const endpoint = id ? 'update_penduduk_miskin.php' : 'save_penduduk_miskin.php'; + const endpoint = id ? 'rancangan_sistem/update_penduduk_miskin.php' : 'rancangan_sistem/save_penduduk_miskin.php'; if (id) { formData.append('id', id); } @@ -3160,8 +3160,8 @@ const formData = new FormData(); formData.append('id', id); - fetch('delete_penduduk_miskin.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'delete_penduduk_miskin.php')) + fetch('rancangan_sistem/delete_penduduk_miskin.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'rancangan_sistem/delete_penduduk_miskin.php')) .then(data => { if (data.status === 'success') { showMessage('🗑️ Data penduduk miskin berhasil dihapus', 'bg-orange-600 text-white'); @@ -3206,7 +3206,7 @@ function loadRumahIbadah(force = false) { if (!force && (document.hidden || suppressAutoReload)) return; - fetch('get_rumah_ibadah.php') + fetch('rancangan_sistem/get_rumah_ibadah.php') .then(res => { if (!res.ok) throw new Error('HTTP Error: ' + res.status); return res.text(); @@ -3250,7 +3250,7 @@ function loadPendudukMiskin(force = false) { if (!force && (document.hidden || suppressAutoReload)) return; - fetch('get_penduduk_miskin.php') + fetch('rancangan_sistem/get_penduduk_miskin.php') .then(res => { if (!res.ok) throw new Error('HTTP Error: ' + res.status); return res.text(); @@ -3566,7 +3566,7 @@ function loadFeatures(force = false) { if (!force && (document.hidden || suppressAutoReload || isFeatureDrawing || isFeatureSaving)) return; - fetch('get_features.php') + fetch('layer_groups_choropleth/get_features.php') .then(res => { if (!res.ok) throw new Error('HTTP Error: ' + res.status); return res.text(); @@ -3638,8 +3638,8 @@ formData.append('nilai', nilai); isFeatureSaving = true; - fetch('save_feature.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'save_feature.php')) + fetch('layer_groups_choropleth/save_feature.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'layer_groups_choropleth/save_feature.php')) .then(data => { if (data.status === 'success') { showMessage('✅ Fitur berhasil disimpan', 'bg-green-600 text-white'); @@ -3762,8 +3762,8 @@ const formData = new FormData(); Object.entries(payload).forEach(([key, value]) => formData.append(key, value)); - fetch('update_feature.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'update_feature.php')) + fetch('layer_groups_choropleth/update_feature.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'layer_groups_choropleth/update_feature.php')) .then(data => { if (data.status === 'success') { layer.featureData.nama_objek = payload.nama; @@ -3830,8 +3830,8 @@ const formData = new FormData(); Object.entries(payload).forEach(([key, value]) => formData.append(key, value)); - fetch('update_feature.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'update_feature.php')) + fetch('layer_groups_choropleth/update_feature.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'layer_groups_choropleth/update_feature.php')) .then(data => { if (data.status === 'success') { layer.featureData.geometry_data = JSON.parse(payload.geometry); @@ -3859,8 +3859,8 @@ const formData = new FormData(); formData.append('id', id); - fetch('delete_feature.php', { method: 'POST', body: formData }) - .then(res => parseJsonResponse(res, 'delete_feature.php')) + fetch('layer_groups_choropleth/delete_feature.php', { method: 'POST', body: formData }) + .then(res => parseJsonResponse(res, 'layer_groups_choropleth/delete_feature.php')) .then(data => { if (data.status === 'success') { if (layer) removeSpatialFeatureLayer(layer, layer.featureType || 'polyline'); diff --git a/rancangan_sistem/README.md b/rancangan_sistem/README.md index 065fe72..0af0866 100644 --- a/rancangan_sistem/README.md +++ b/rancangan_sistem/README.md @@ -3,18 +3,21 @@ Ringkasan singkat: rancangan ini menggabungkan data titik (SPBU, fasilitas), jaringan jalan (polyline), parsel tanah (polygon dengan luas otomatis), dan peta tematik (choropleth). Tujuan: menyediakan basis data spasial untuk analisis kebutuhan bantuan, akses layanan, dan prioritas intervensi. Komponen: + - Data: sampel sensus, kemiskinan, infrastruktur, peta batas administrasi, penggunaan lahan, parsel tanah. - Backend: API PHP ringan untuk CRUD GeoJSON + penyimpanan file atau database spatial (PostGIS direkomendasikan). - Frontend: Leaflet + plugins (Draw, Turf.js) untuk editing, pengukuran, dan visualisasi layer groups. - Analitik: agregasi statistik per kelurahan/kecamatan untuk choropleth (tingkat kemiskinan, akses fasilitas). Alur kerja singkat: + 1. Kumpulkan & validasi data atribut (nama, id, status ekonomis, luas parsel). 2. Masukkan ke sistem: titik/line/polygon. 3. Hitung atribut turunan: luas parsel (m²), distance-to-nearest-facility, road-condition index. 4. Hasilkan peta tematik & laporan untuk prioritisasi intervensi. Rekomendasi teknis singkat: + - Gunakan PostGIS untuk query spasial yang efisien. - Simpan snapshot GeoJSON untuk interoperabilitas. - Bangun API otentikasi dan logging perubahan (audit trail) untuk kebijakan bantuan. @@ -22,8 +25,9 @@ Rekomendasi teknis singkat: Catatan: folder lain di repo ini berisi contoh starter untuk tiap fitur (uji_spbu, fitur_jalan_parsel, layer_groups_choropleth). Global Leaflet loader: + - File: `global/leaflet-loader.js` — tambahkan tag berikut ke halaman HTML Anda untuk memuat Leaflet dari satu sumber global: - + -Gunakan `rancangan_sistem/index.html` sebagai contoh integrasi: halaman akan memanggil `../get_rumah_ibadah.php` dan `../get_penduduk_miskin.php` dari root repository dan menambahkan data ke peta. +Gunakan `rancangan_sistem/index.html` sebagai contoh integrasi: halaman akan memanggil `rancangan_sistem/get_rumah_ibadah.php` dan `rancangan_sistem/get_penduduk_miskin.php` (endpoints lokal di folder yang sama) dan menambahkan data ke peta. diff --git a/rancangan_sistem/delete_penduduk_miskin.php b/rancangan_sistem/delete_penduduk_miskin.php index 472c5ef..daf3487 100644 --- a/rancangan_sistem/delete_penduduk_miskin.php +++ b/rancangan_sistem/delete_penduduk_miskin.php @@ -23,4 +23,4 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { $stmt->close(); } $conn->close(); -?> +?> \ No newline at end of file diff --git a/save_feature.php b/save_feature.php deleted file mode 100644 index f94bcf2..0000000 --- a/save_feature.php +++ /dev/null @@ -1,50 +0,0 @@ - 'error', 'message' => 'Data fitur tidak lengkap']); - $conn->close(); - exit; - } - - $stmt = $conn->prepare("INSERT INTO spatial_features (nama_objek, kategori, status_objek, type, geometry_data, nilai_ukur) VALUES (?, ?, ?, ?, ?, ?)"); - - if (!$stmt) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $conn->error]); - $conn->close(); - exit; - } - - $stmt->bind_param("sssssd", $nama, $kategori, $status, $type, $geometry, $nilai); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Data berhasil disimpan']); - } else { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - $stmt->close(); - $conn->close(); - exit; -} - -http_response_code(405); -echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); -$conn->close(); -?> diff --git a/save_jalan_rusak.php b/save_jalan_rusak.php deleted file mode 100644 index 78ca41e..0000000 --- a/save_jalan_rusak.php +++ /dev/null @@ -1,72 +0,0 @@ - 'error', 'message' => 'Latitude, longitude, dan jenis kerusakan wajib diisi']); - exit; - } - - $gambar = null; - - // Handle file upload - if (isset($_FILES['gambar']) && $_FILES['gambar']['error'] === UPLOAD_ERR_OK) { - $allowed = ['jpg', 'jpeg', 'png', 'gif']; - $filename = $_FILES['gambar']['name']; - $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - - if (!in_array($ext, $allowed)) { - http_response_code(400); - echo json_encode(['status' => 'error', 'message' => 'Format gambar hanya JPG, PNG, GIF']); - exit; - } - - // Buat folder uploads jika belum ada - if (!is_dir('uploads')) { - mkdir('uploads', 0755, true); - } - - // Generate nama file unik - $gambar = 'uploads/' . time() . '_' . basename($filename); - - if (!move_uploaded_file($_FILES['gambar']['tmp_name'], $gambar)) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => 'Gagal upload gambar']); - exit; - } - } - - $stmt = $conn->prepare("INSERT INTO jalan_rusak (latitude, longitude, jenis_kerusakan, deskripsi, severity, gambar) VALUES (?, ?, ?, ?, ?, ?)"); - - if (!$stmt) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $conn->error]); - exit; - } - - $stmt->bind_param("ddssss", $latitude, $longitude, $jenis_kerusakan, $deskripsi, $severity, $gambar); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Laporan jalan rusak berhasil disimpan', 'id' => $stmt->insert_id]); - } else { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); - $conn->close(); - exit; -} - -http_response_code(405); -echo json_encode(['status' => 'error', 'message' => 'Method tidak diizinkan']); -$conn->close(); -?> diff --git a/save_penduduk_miskin.php b/save_penduduk_miskin.php deleted file mode 100644 index 18b4c51..0000000 --- a/save_penduduk_miskin.php +++ /dev/null @@ -1,80 +0,0 @@ -query("SELECT id, nama, latitude, longitude FROM rumah_ibadah ORDER BY created_at DESC"); - if (!$result || $result->num_rows === 0) { - return null; - } - - $nearest = null; - while ($row = $result->fetch_assoc()) { - $distance = distanceMeters($lat, $lng, (float)$row['latitude'], (float)$row['longitude']); - if ($nearest === null || $distance < $nearest['distance']) { - $nearest = [ - 'id' => (int)$row['id'], - 'nama' => $row['nama'], - 'distance' => $distance - ]; - } - } - - return $nearest; -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $namaKetuaKk = trim($_POST['nama_ketua_kk'] ?? ''); - $jumlahAnggota = (int)($_POST['jumlah_anggota'] ?? 0); - $lat = $_POST['latitude'] ?? null; - $lng = $_POST['longitude'] ?? null; - $rumahIbadahId = $_POST['rumah_ibadah_id'] ?? null; - $rumahIbadahNama = trim($_POST['rumah_ibadah_nama'] ?? ''); - $jarak = $_POST['jarak_ke_rumah_ibadah_m'] ?? null; - - if ($namaKetuaKk === '' || $jumlahAnggota <= 0 || $lat === null || $lng === null) { - echo json_encode(['status' => 'error', 'message' => 'Data penduduk miskin tidak lengkap']); - $conn->close(); - exit; - } - - $lat = (float)$lat; - $lng = (float)$lng; - $nearest = findNearestRumahIbadah($conn, $lat, $lng); - - if (!$nearest) { - echo json_encode(['status' => 'error', 'message' => 'Tambahkan rumah ibadah terlebih dahulu']); - $conn->close(); - exit; - } - - $jarak = $nearest['distance']; - $rumahIbadahId = $nearest['id']; - $rumahIbadahNama = $nearest['nama']; - - $stmt = $conn->prepare("INSERT INTO penduduk_miskin (nama_ketua_kk, jumlah_anggota, latitude, longitude, rumah_ibadah_id, rumah_ibadah_nama, jarak_ke_rumah_ibadah_m) VALUES (?, ?, ?, ?, ?, ?, ?)"); - $stmt->bind_param("siddisd", $namaKetuaKk, $jumlahAnggota, $lat, $lng, $rumahIbadahId, $rumahIbadahNama, $jarak); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Penduduk miskin berhasil disimpan']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} -$conn->close(); -?> \ No newline at end of file diff --git a/save_rumah_ibadah.php b/save_rumah_ibadah.php deleted file mode 100644 index 0f2481f..0000000 --- a/save_rumah_ibadah.php +++ /dev/null @@ -1,35 +0,0 @@ - 'error', 'message' => 'Data rumah ibadah tidak lengkap']); - $conn->close(); - exit; - } - - $lat = (float)$lat; - $lng = (float)$lng; - $radius = max(50, (int)$radius); - - $stmt = $conn->prepare("INSERT INTO rumah_ibadah (nama, alamat, pic, latitude, longitude, radius_m) VALUES (?, ?, ?, ?, ?, ?)"); - $stmt->bind_param("sssddi", $nama, $alamat, $pic, $lat, $lng, $radius); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah berhasil disimpan']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} -$conn->close(); -?> \ No newline at end of file diff --git a/test_features.html b/test_features.html index ffc8094..f2e8ee5 100644 --- a/test_features.html +++ b/test_features.html @@ -41,19 +41,19 @@

Load Rumah Ibadah Data

- +

Load Penduduk Miskin Data

- +

Load Jalan Rusak Data

- +
@@ -158,7 +158,7 @@ async function testDatabase() { async function testLoadRumahIbadah() { try { - const response = await fetch('get_rumah_ibadah.php'); + const response = await fetch('rancangan_sistem/get_rumah_ibadah.php'); const text = await response.text(); const data = JSON.parse(text); @@ -171,7 +171,7 @@ async function testLoadRumahIbadah() { async function testLoadPendudukMiskin() { try { - const response = await fetch('get_penduduk_miskin.php'); + const response = await fetch('rancangan_sistem/get_penduduk_miskin.php'); const text = await response.text(); const data = JSON.parse(text); @@ -184,7 +184,7 @@ async function testLoadPendudukMiskin() { async function testLoadJalanRusak() { try { - const response = await fetch('get_jalan_rusak.php'); + const response = await fetch('fitur_jalan_parsel/get_jalan_rusak.php'); const text = await response.text(); const data = JSON.parse(text); @@ -205,7 +205,7 @@ async function testSaveRumahIbadah() { formData.append('longitude', document.getElementById('lngRumah').value); formData.append('radius_m', document.getElementById('radiusRumah').value); - const response = await fetch('save_rumah_ibadah.php', { + const response = await fetch('rancangan_sistem/save_rumah_ibadah.php', { method: 'POST', body: formData }); diff --git a/update_feature.php b/update_feature.php deleted file mode 100644 index e8ed329..0000000 --- a/update_feature.php +++ /dev/null @@ -1,45 +0,0 @@ - 'error', 'message' => 'Data fitur tidak lengkap']); - $conn->close(); - exit; - } - - $stmt = $conn->prepare("UPDATE spatial_features SET nama_objek = ?, kategori = ?, status_objek = ?, type = ?, geometry_data = ?, nilai_ukur = ? WHERE id = ?"); - - if (!$stmt) { - http_response_code(500); - echo json_encode(['status' => 'error', 'message' => $conn->error]); - $conn->close(); - exit; - } - - $stmt->bind_param("sssssdi", $nama, $kategori, $status, $type, $geometry, $nilai, $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Fitur berhasil diperbarui']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} - -$conn->close(); -?> \ No newline at end of file diff --git a/update_penduduk_miskin.php b/update_penduduk_miskin.php deleted file mode 100644 index b92f2c9..0000000 --- a/update_penduduk_miskin.php +++ /dev/null @@ -1,82 +0,0 @@ -query("SELECT id, nama, latitude, longitude FROM rumah_ibadah ORDER BY created_at DESC"); - if (!$result || $result->num_rows === 0) { - return null; - } - - $nearest = null; - while ($row = $result->fetch_assoc()) { - $distance = distanceMeters($lat, $lng, (float)$row['latitude'], (float)$row['longitude']); - if ($nearest === null || $distance < $nearest['distance']) { - $nearest = [ - 'id' => (int)$row['id'], - 'nama' => $row['nama'], - 'distance' => $distance - ]; - } - } - - return $nearest; -} - -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $id = (int)($_POST['id'] ?? 0); - $namaKetuaKk = trim($_POST['nama_ketua_kk'] ?? ''); - $jumlahAnggota = (int)($_POST['jumlah_anggota'] ?? 0); - $lat = $_POST['latitude'] ?? null; - $lng = $_POST['longitude'] ?? null; - $rumahIbadahId = $_POST['rumah_ibadah_id'] ?? null; - $rumahIbadahNama = trim($_POST['rumah_ibadah_nama'] ?? ''); - $jarak = $_POST['jarak_ke_rumah_ibadah_m'] ?? null; - - if ($id <= 0 || $namaKetuaKk === '' || $jumlahAnggota <= 0 || $lat === null || $lng === null) { - echo json_encode(['status' => 'error', 'message' => 'Data penduduk miskin tidak lengkap']); - $conn->close(); - exit; - } - - $lat = (float)$lat; - $lng = (float)$lng; - $nearest = findNearestRumahIbadah($conn, $lat, $lng); - - if (!$nearest) { - echo json_encode(['status' => 'error', 'message' => 'Tambahkan rumah ibadah terlebih dahulu']); - $conn->close(); - exit; - } - - $jarak = $nearest['distance']; - $rumahIbadahId = $nearest['id']; - $rumahIbadahNama = $nearest['nama']; - - $stmt = $conn->prepare("UPDATE penduduk_miskin SET nama_ketua_kk = ?, jumlah_anggota = ?, latitude = ?, longitude = ?, rumah_ibadah_id = ?, rumah_ibadah_nama = ?, jarak_ke_rumah_ibadah_m = ? WHERE id = ?"); - $stmt->bind_param("siddisdi", $namaKetuaKk, $jumlahAnggota, $lat, $lng, $rumahIbadahId, $rumahIbadahNama, $jarak, $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Data penduduk miskin berhasil diperbarui']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} - -$conn->close(); -?> diff --git a/update_rumah_ibadah.php b/update_rumah_ibadah.php deleted file mode 100644 index d0523ef..0000000 --- a/update_rumah_ibadah.php +++ /dev/null @@ -1,36 +0,0 @@ - 'error', 'message' => 'Data rumah ibadah tidak lengkap']); - $conn->close(); - exit; - } - - $lat = (float)$lat; - $lng = (float)$lng; - $radius = max(50, (int)$radius); - - $stmt = $conn->prepare("UPDATE rumah_ibadah SET nama = ?, alamat = ?, pic = ?, latitude = ?, longitude = ?, radius_m = ? WHERE id = ?"); - $stmt->bind_param("sssddii", $nama, $alamat, $pic, $lat, $lng, $radius, $id); - - if ($stmt->execute()) { - echo json_encode(['status' => 'success', 'message' => 'Rumah ibadah berhasil diperbarui']); - } else { - echo json_encode(['status' => 'error', 'message' => $stmt->error]); - } - - $stmt->close(); -} -$conn->close(); -?> \ No newline at end of file