commit 28a7b0489311f1cef8848e1285863d3df45541ad Author: unknown Date: Mon Jun 8 20:51:21 2026 +0700 Pembaruan pertama: Implementasi WebGIS CRUD dan Layer SPBU diff --git a/01/edit_feature.php b/01/edit_feature.php new file mode 100644 index 0000000..a8b0095 --- /dev/null +++ b/01/edit_feature.php @@ -0,0 +1,25 @@ +prepare("UPDATE jalan SET nama_jalan = ?, status_jalan = ? WHERE id = ?"); + $stmt->execute([$data['nama'], $data['status'], $data['id']]); + } + else if ($data['type'] === 'persil') { + $stmt = $koneksi_pdo->prepare("UPDATE persil_tanah SET nomor_persil = ?, status_milik = ? WHERE id = ?"); + $stmt->execute([$data['nama'], $data['status'], $data['id']]); + } + else if ($data['type'] === 'spbu') { + // Menggunakan kolom is_24jam sebagai penanda status operasional + $stmt = $koneksi_pdo->prepare("UPDATE spbu_locations SET nama_spbu = ?, is_24jam = ? WHERE id = ?"); + $stmt->execute([$data['nama'], $data['status'], $data['id']]); + } + echo json_encode(["status" => "success"]); +} catch (PDOException $e) { + echo json_encode(["status" => "error", "message" => $e->getMessage()]); +} +?> \ No newline at end of file diff --git a/01/hapus_feature.php b/01/hapus_feature.php new file mode 100644 index 0000000..2b9f14d --- /dev/null +++ b/01/hapus_feature.php @@ -0,0 +1,29 @@ +prepare("DELETE FROM jalan WHERE id = ?"); + } + else if ($data['type'] === 'persil') { + $stmt = $koneksi_pdo->prepare("DELETE FROM persil_tanah WHERE id = ?"); + } + else if ($data['type'] === 'spbu') { + $stmt = $koneksi_pdo->prepare("DELETE FROM spbu WHERE id = ?"); + } + + if (isset($stmt)) { + $stmt->execute([$data['id']]); + } + + echo json_encode(["status" => "success"]); +} catch (PDOException $e) { + echo json_encode(["status" => "error", "message" => $e->getMessage()]); +} +?> \ No newline at end of file diff --git a/01/index.html b/01/index.html new file mode 100644 index 0000000..55401e0 --- /dev/null +++ b/01/index.html @@ -0,0 +1,277 @@ + + + + + + WebGIS Pro - Layer Control SPBU + + + + + + + + + + + +
+ + + + \ No newline at end of file diff --git a/01/koneksi.php b/01/koneksi.php new file mode 100644 index 0000000..8de47eb --- /dev/null +++ b/01/koneksi.php @@ -0,0 +1,33 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + +} catch (PDOException $kesalahan_sistem) { + // Menghentikan proses secara aman dan mengembalikan pesan kegagalan terformat JSON + echo json_encode([ + "status" => "error", + "message" => "Koneksi ke basis data gagal dilakukan: " . $kesalahan_sistem->getMessage() + ]); + exit; +} +?> \ No newline at end of file diff --git a/01/simpan.php b/01/simpan.php new file mode 100644 index 0000000..2f0ef1b --- /dev/null +++ b/01/simpan.php @@ -0,0 +1,48 @@ + "error", "message" => "Koneksi Gagal: " . mysqli_connect_error()]); + exit; +} + +// 3. Menerima Data dari JavaScript (index.html) +$input = file_get_contents('php://input'); +$data = json_decode($input, true); + +if ($data) { + // Membersihkan data agar aman dari serangan SQL Injection + $nama = mysqli_real_escape_string($conn, $data['nama']); + $jam24 = mysqli_real_escape_string($conn, $data['jam24']); + $hp = mysqli_real_escape_string($conn, $data['hp']); + $lat = $data['lat']; + $lng = $data['lng']; + + // 4. Query Memasukkan Data ke Tabel + $query = "INSERT INTO spbu_locations (nama_spbu, is_24jam, no_hp, lat, lng) + VALUES ('$nama', '$jam24', '$hp', '$lat', '$lng')"; + + if (mysqli_query($conn, $query)) { + // Jika berhasil, kirim sinyal sukses + echo json_encode(["status" => "success"]); + } else { + // Jika query gagal, tampilkan errornya + echo json_encode(["status" => "error", "message" => mysqli_error($conn)]); + } +} else { + echo json_encode(["status" => "error", "message" => "Data kosong atau format salah"]); +} + +// Tutup koneksi untuk menghemat memori +mysqli_close($conn); +?> \ No newline at end of file diff --git a/01/simpan_feature.php b/01/simpan_feature.php new file mode 100644 index 0000000..043e103 --- /dev/null +++ b/01/simpan_feature.php @@ -0,0 +1,30 @@ + "error", "message" => "Data tidak valid"]); + exit; +} + +try { + if ($data['type'] === 'jalan') { + $stmt = $koneksi_pdo->prepare("INSERT INTO jalan (nama_jalan, status_jalan, panjang_m, geojson) VALUES (?, ?, ?, ?)"); + $stmt->execute([$data['nama'], $data['status'], $data['besaran'], $data['geojson']]); + } + else if ($data['type'] === 'persil') { + $stmt = $koneksi_pdo->prepare("INSERT INTO persil_tanah (nomor_persil, status_milik, luas_m2, geojson) VALUES (?, ?, ?, ?)"); + $stmt->execute([$data['nama'], $data['status'], $data['besaran'], $data['geojson']]); + } + else if ($data['type'] === 'spbu') { + // Skema disesuaikan sepenuhnya dengan tabel spbu_locations peninggalan proyek sebelumnya + $stmt = $koneksi_pdo->prepare("INSERT INTO spbu_locations (nama_spbu, is_24jam, no_hp, lat, lng) VALUES (?, ?, ?, ?, ?)"); + $stmt->execute([$data['nama'], $data['jam24'], $data['hp'], $data['lat'], $data['lng']]); + } + echo json_encode(["status" => "success"]); +} catch (PDOException $e) { + echo json_encode(["status" => "error", "message" => $e->getMessage()]); +} +?> \ No newline at end of file diff --git a/01/tampil_data.php b/01/tampil_data.php new file mode 100644 index 0000000..81d96ec --- /dev/null +++ b/01/tampil_data.php @@ -0,0 +1,29 @@ + "error", "message" => "Koneksi Gagal"]); + exit; +} + +// Ambil semua data dari tabel +$query = "SELECT * FROM spbu_locations"; +$result = mysqli_query($conn, $query); + +$data_spbu = []; +while ($row = mysqli_fetch_assoc($result)) { + $data_spbu[] = $row; +} + +// Kirim data ke file HTML dalam bentuk JSON +echo json_encode(["status" => "success", "data" => $data_spbu]); + +mysqli_close($conn); +?> \ No newline at end of file diff --git a/01/tampil_feature.php b/01/tampil_feature.php new file mode 100644 index 0000000..1622a5a --- /dev/null +++ b/01/tampil_feature.php @@ -0,0 +1,31 @@ +query("SELECT * FROM data_jalan"); + $data_jalan = $query_jalan->fetchAll(PDO::FETCH_ASSOC); + + // Memanggil tabel persil sesuai skema Anda + $query_persil = $koneksi_pdo->query("SELECT * FROM data_persil"); + $data_persil = $query_persil->fetchAll(PDO::FETCH_ASSOC); + + // Memanggil tabel SPBU + $query_spbu = $koneksi_pdo->query("SELECT * FROM spbu_locations"); + $data_spbu = $query_spbu->fetchAll(PDO::FETCH_ASSOC); + + echo json_encode([ + "status" => "success", + "jalan" => $data_jalan, + "persil" => $data_persil, + "spbu" => $data_spbu + ]); + +} catch (PDOException $e) { + echo json_encode(["status" => "error", "message" => $e->getMessage()]); +} +?> \ No newline at end of file diff --git a/01/tes1.html b/01/tes1.html new file mode 100644 index 0000000..2ab4723 --- /dev/null +++ b/01/tes1.html @@ -0,0 +1,70 @@ + + + + + + + Quick Start - Leaflet + + + + + + + +
+ + + + \ No newline at end of file