From fdf1e36cd38277f509f4e4380c9ad65a84b34729 Mon Sep 17 00:00:00 2001 From: SatryaIrvannurYudha Date: Thu, 4 Jun 2026 21:28:53 +0700 Subject: [PATCH] Initial commit WebGIS Poverty Mapping --- ambil.php | 91 ++++++++ ambil_debug.php | 4 + buat_db.php | 50 +++++ cek_kolom.php | 22 ++ create_tables.sql | 33 +++ debug_ambil.php | 32 +++ hapus_jalan.php | 14 ++ hapus_parsil.php | 14 ++ hapus_spbu.php | 14 ++ index.html | 81 +++++++ index.php | 348 ++++++++++++++++++++++++++++++ koneksi.php | 6 + radius.php | 538 ++++++++++++++++++++++++++++++++++++++++++++++ simpan_jalan.php | 20 ++ simpan_parsil.php | 19 ++ simpan_spbu.php | 21 ++ test500.php | 9 + update_posisi.php | 17 ++ 18 files changed, 1333 insertions(+) create mode 100644 ambil.php create mode 100644 ambil_debug.php create mode 100644 buat_db.php create mode 100644 cek_kolom.php create mode 100644 create_tables.sql create mode 100644 debug_ambil.php create mode 100644 hapus_jalan.php create mode 100644 hapus_parsil.php create mode 100644 hapus_spbu.php create mode 100644 index.html create mode 100644 index.php create mode 100644 koneksi.php create mode 100644 radius.php create mode 100644 simpan_jalan.php create mode 100644 simpan_parsil.php create mode 100644 simpan_spbu.php create mode 100644 test500.php create mode 100644 update_posisi.php diff --git a/ambil.php b/ambil.php new file mode 100644 index 0000000..cb31dce --- /dev/null +++ b/ambil.php @@ -0,0 +1,91 @@ + "error", "message" => "Gagal konek DB")); + exit; +} +if ($_SERVER['REQUEST_METHOD'] === 'GET') { + $res = array("ibadah" => array(), "penduduk" => array()); + $qI = mysqli_query($conn, "SELECT id, nama, latitude, longitude, radius FROM tabel_ibadah"); + if($qI){ + while($r = mysqli_fetch_assoc($qI)) { + $res["ibadah"][] = array( + "id" => (int)$r['id'], + "nama_ibadah" => $r['nama'], + "latitude" => (float)$r['latitude'], + "longitude" => (float)$r['longitude'], + "radius" => (int)$r['radius'] + ); + } + } + $qP = mysqli_query($conn, "SELECT id, nama, latitude, longitude, status_warna FROM tabel_penduduk"); + if($qP){ + while($r = mysqli_fetch_assoc($qP)) { + $res["penduduk"][] = array( + "id" => (int)$r['id'], + "nama_penduduk" => $r['nama'], + "latitude" => (float)$r['latitude'], + "longitude" => (float)$r['longitude'], + "status_warna" => $r['status_warna'] + ); + } + } + echo json_encode($res); + exit; +} +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + if (isset($_POST['type']) && $_POST['type'] === 'ibadah') { + $nama = mysqli_real_escape_string($conn, $_POST['nama_ibadah']); + $lat = (float)$_POST['latitude']; + $lng = (float)$_POST['longitude']; + $rad = (int)$_POST['radius']; + $sql = "INSERT INTO tabel_ibadah (nama, latitude, longitude, radius) VALUES ('$nama', $lat, $lng, $rad)"; + if (mysqli_query($conn, $sql)) { + echo json_encode(array("status" => "success", "message" => "Berhasil Simpan")); + } else { + echo json_encode(array("status" => "error", "message" => mysqli_error($conn))); + } + exit; + } + if (isset($_POST['type']) && $_POST['type'] === 'penduduk') { + $nama = mysqli_real_escape_string($conn, $_POST['nama_penduduk']); + $lat = (float)$_POST['latitude']; + $lng = (float)$_POST['longitude']; + $sql = "INSERT INTO tabel_penduduk (nama, latitude, longitude, status_warna) VALUES ('$nama', $lat, $lng, 'Merah')"; + if (mysqli_query($conn, $sql)) { + echo json_encode(array("status" => "success", "message" => "Berhasil Simpan")); + } else { + echo json_encode(array("status" => "error", "message" => mysqli_error($conn))); + } + exit; + } + if (isset($_POST['action']) && $_POST['action'] === 'update_warna') { + $id = (int)$_POST['id']; + $warna = mysqli_real_escape_string($conn, $_POST['status_warna']); + $sql = "UPDATE tabel_penduduk SET status_warna = '$warna' WHERE id = $id"; + if (mysqli_query($conn, $sql)) { + echo json_encode(array("status" => "success", "message" => "Update OK")); + } else { + echo json_encode(array("status" => "error", "message" => mysqli_error($conn))); + } + exit; + } + + // Hapus Data + if (isset($_POST['action']) && $_POST['action'] === 'hapus') { + $id = (int)$_POST['id']; + $type = $_POST['type_hapus']; + $table = ($type === 'ibadah') ? 'tabel_ibadah' : 'tabel_penduduk'; + + $sql = "DELETE FROM $table WHERE id = $id"; + if (mysqli_query($conn, $sql)) { + echo json_encode(array("status" => "success", "message" => "Data berhasil dihapus")); + } else { + echo json_encode(array("status" => "error", "message" => mysqli_error($conn))); + } + exit; + } +} diff --git a/ambil_debug.php b/ambil_debug.php new file mode 100644 index 0000000..bebeb26 --- /dev/null +++ b/ambil_debug.php @@ -0,0 +1,4 @@ +"; +} else { + echo "Gagal buat database: " . mysqli_error($conn) . "
"; +} + +// 2. Pilih Database +mysqli_select_db($conn, "webgis"); + +// 3. Buat Tabel Ibadah +$t1 = "CREATE TABLE IF NOT EXISTS `tabel_ibadah` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `nama_ibadah` VARCHAR(150) NOT NULL, + `latitude` DOUBLE NOT NULL, + `longitude` DOUBLE NOT NULL, + `radius` INT(11) NOT NULL DEFAULT 500, + PRIMARY KEY (`id`) +)"; +if (mysqli_query($conn, $t1)) { + echo "2. Tabel 'tabel_ibadah' SIAP.
"; +} + +// 4. Buat Tabel Penduduk +$t2 = "CREATE TABLE IF NOT EXISTS `tabel_penduduk` ( + `id` INT(11) NOT NULL AUTO_INCREMENT, + `nama_penduduk` VARCHAR(150) NOT NULL, + `latitude` DOUBLE NOT NULL, + `longitude` DOUBLE NOT NULL, + `status_warna` ENUM('Merah','Hijau') NOT NULL DEFAULT 'Merah', + PRIMARY KEY (`id`) +)"; +if (mysqli_query($conn, $t2)) { + echo "3. Tabel 'tabel_penduduk' SIAP.
"; +} + +echo "
Selesai! Silakan coba lagi fitur Radius-nya."; +?> diff --git a/cek_kolom.php b/cek_kolom.php new file mode 100644 index 0000000..9eb9600 --- /dev/null +++ b/cek_kolom.php @@ -0,0 +1,22 @@ +query("SHOW TABLES LIKE '$t'"); + echo "$t: " . ($r && $r->num_rows > 0 ? "ADA" : "BELUM ADA") . PHP_EOL; +} + +echo PHP_EOL . "=== CEK PREPARE ===" . PHP_EOL; +$s = $conn->prepare("SELECT id FROM tabel_ibadah LIMIT 1"); +if ($s === false) { + echo "prepare() GAGAL: " . $conn->error . PHP_EOL; +} else { + echo "prepare() OK" . PHP_EOL; + $s->close(); +} + +echo PHP_EOL . "=== CEK ob_start CONFLICT ===" . PHP_EOL; +echo "ob_get_level: " . ob_get_level() . PHP_EOL; diff --git a/hapus_jalan.php b/hapus_jalan.php new file mode 100644 index 0000000..96a0513 --- /dev/null +++ b/hapus_jalan.php @@ -0,0 +1,14 @@ + diff --git a/hapus_parsil.php b/hapus_parsil.php new file mode 100644 index 0000000..6b85afc --- /dev/null +++ b/hapus_parsil.php @@ -0,0 +1,14 @@ + diff --git a/hapus_spbu.php b/hapus_spbu.php new file mode 100644 index 0000000..90ed0d2 --- /dev/null +++ b/hapus_spbu.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..6c625be --- /dev/null +++ b/index.html @@ -0,0 +1,81 @@ + + + + + + + + + Quick Start - Leaflet + + + + + + + + + + + + + + +
+ + + + + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..be39b19 --- /dev/null +++ b/index.php @@ -0,0 +1,348 @@ + + + + + + + WebGIS Pro - Pontianak + + + + + + + + + + + + + +
+ + + + + + + + \ No newline at end of file diff --git a/koneksi.php b/koneksi.php new file mode 100644 index 0000000..560360f --- /dev/null +++ b/koneksi.php @@ -0,0 +1,6 @@ + + + + + + Analisis Radius Bantuan — WebGIS + + + + + + + + + + + +
+
+
0
+
Rumah Ibadah
+
+
+
0
+
Tercakup
+
+
+
0
+
Belum Tercakup
+
+
+ + +
+ +
+ + + + + + diff --git a/simpan_jalan.php b/simpan_jalan.php new file mode 100644 index 0000000..c27e25a --- /dev/null +++ b/simpan_jalan.php @@ -0,0 +1,20 @@ +alert('Data Jalan Berhasil Disimpan!'); window.location='index.php';"; + } else { + echo "Error SQL: " . mysqli_error($conn); + } +} +?> \ No newline at end of file diff --git a/simpan_parsil.php b/simpan_parsil.php new file mode 100644 index 0000000..0976132 --- /dev/null +++ b/simpan_parsil.php @@ -0,0 +1,19 @@ +alert('Data Parsil Berhasil Disimpan!'); window.location='index.php';"; + } else { + echo "Error SQL: " . mysqli_error($conn); + } +} +?> \ No newline at end of file diff --git a/simpan_spbu.php b/simpan_spbu.php new file mode 100644 index 0000000..97b7f6c --- /dev/null +++ b/simpan_spbu.php @@ -0,0 +1,21 @@ + \ No newline at end of file diff --git a/test500.php b/test500.php new file mode 100644 index 0000000..4137bed --- /dev/null +++ b/test500.php @@ -0,0 +1,9 @@ + \ No newline at end of file