commit 433efc445701f3a6587e2da6db90c063b9bfe99e Author: Farha Date: Tue Apr 7 17:17:55 2026 +0700 Initial commit diff --git a/db_config.php b/db_config.php new file mode 100644 index 0000000..d31baf8 --- /dev/null +++ b/db_config.php @@ -0,0 +1,15 @@ +set_charset('utf8mb4'); + +if ($conn->connect_error) { + http_response_code(500); + echo json_encode(['status' => 'error', 'message' => 'Koneksi gagal: ' . $conn->connect_error]); + exit; +} +?> \ No newline at end of file diff --git a/delete_feature.php b/delete_feature.php new file mode 100644 index 0000000..35148d7 --- /dev/null +++ b/delete_feature.php @@ -0,0 +1,36 @@ + '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_location.php b/delete_location.php new file mode 100644 index 0000000..ef9aa44 --- /dev/null +++ b/delete_location.php @@ -0,0 +1,19 @@ +prepare("DELETE FROM locations WHERE id = ?"); + $stmt->bind_param("i", $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data 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 new file mode 100644 index 0000000..c210eb8 --- /dev/null +++ b/get_features.php @@ -0,0 +1,41 @@ +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_location.php b/get_location.php new file mode 100644 index 0000000..d003acd --- /dev/null +++ b/get_location.php @@ -0,0 +1,25 @@ +query($sql); + +$locations = []; + +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()) { + $locations[] = $row; + } +} + +echo json_encode($locations); +$conn->close(); +?> \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..f51c8d1 --- /dev/null +++ b/index.html @@ -0,0 +1,1296 @@ + + + + + + Sistem GIS Manajemen SPBU + + + + + + + + + + + +
+
+ +
+
+
+

GIS SPBU

+

Mode default hanya menampilkan peta dan atribut data yang sudah dibuat.

+
+ +
+
Mengecek koneksi ke database...
+
+ Total SPBU + 0 +
+
+ + + + +
+ +
+ Buka 24 Jam + Jam Terbatas +
+
+ + +
+ + + + + + + + +
+ + + +
+ + + + + + + + \ No newline at end of file diff --git a/save_feature.php b/save_feature.php new file mode 100644 index 0000000..f94bcf2 --- /dev/null +++ b/save_feature.php @@ -0,0 +1,50 @@ + '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_location.php b/save_location.php new file mode 100644 index 0000000..00673b4 --- /dev/null +++ b/save_location.php @@ -0,0 +1,30 @@ + 'error', 'message' => 'Data tidak lengkap']); + exit; + } + + $stmt = $conn->prepare("INSERT INTO locations (nama, nomor, buka_24jam, latitude, longitude) VALUES (?, ?, ?, ?, ?)"); + $stmt->bind_param("sssdd", $nama, $nomor, $status, $lat, $lng); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data berhasil disimpan']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + + $stmt->close(); +} +$conn->close(); +?> \ No newline at end of file diff --git a/update_coords.php b/update_coords.php new file mode 100644 index 0000000..a46c080 --- /dev/null +++ b/update_coords.php @@ -0,0 +1,21 @@ +prepare("UPDATE locations SET latitude = ?, longitude = ? WHERE id = ?"); + $stmt->bind_param("ddi", $lat, $lng, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Lokasi diperbarui']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); +} +$conn->close(); +?> \ No newline at end of file diff --git a/update_details.php b/update_details.php new file mode 100644 index 0000000..8e3c9ae --- /dev/null +++ b/update_details.php @@ -0,0 +1,22 @@ +prepare("UPDATE locations SET nama = ?, nomor = ?, buka_24jam = ? WHERE id = ?"); + $stmt->bind_param("sssi", $nama, $nomor, $status, $id); + + if ($stmt->execute()) { + echo json_encode(['status' => 'success', 'message' => 'Data diperbarui']); + } else { + echo json_encode(['status' => 'error', 'message' => $stmt->error]); + } + $stmt->close(); +} +$conn->close(); +?> \ No newline at end of file diff --git a/update_feature.php b/update_feature.php new file mode 100644 index 0000000..e8ed329 --- /dev/null +++ b/update_feature.php @@ -0,0 +1,45 @@ + '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