initial commit
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
$result = $conn->query("SELECT * FROM jalan ORDER BY created_at DESC");
|
||||
$data = array();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'ID tidak valid']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM jalan WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Data jalan berhasil dihapus']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
$geojson = $_POST['geojson'] ?? '';
|
||||
$panjang = floatval($_POST['panjang'] ?? 0);
|
||||
|
||||
if (empty($nama) || empty($status) || empty($geojson) || $panjang <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Data tidak lengkap']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO jalan (nama, status, panjang, geojson) VALUES (?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ssds", $nama, $status, $panjang, $geojson);
|
||||
|
||||
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();
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
|
||||
// Jika ada geojson, update geometri juga
|
||||
if (isset($_POST['geojson'])) {
|
||||
$geojson = $_POST['geojson'];
|
||||
$panjang = floatval($_POST['panjang'] ?? 0);
|
||||
$sql = "UPDATE jalan SET nama = ?, status = ?, geojson = ?, panjang = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("sssdi", $nama, $status, $geojson, $panjang, $id);
|
||||
} else {
|
||||
// Hanya update info
|
||||
$sql = "UPDATE jalan SET nama = ?, status = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ssi", $nama, $status, $id);
|
||||
}
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
$result = $conn->query("SELECT * FROM parsil_tanah ORDER BY created_at DESC");
|
||||
$data = array();
|
||||
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'ID tidak valid']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM parsil_tanah WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Data parsil berhasil dihapus']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
$geojson = $_POST['geojson'] ?? '';
|
||||
$luas = floatval($_POST['luas'] ?? 0);
|
||||
|
||||
if (empty($nama) || empty($status) || empty($geojson) || $luas <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Data tidak lengkap']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO parsil_tanah (nama, status, luas, geojson) VALUES (?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ssds", $nama, $status, $luas, $geojson);
|
||||
|
||||
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();
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$status = trim($_POST['status'] ?? '');
|
||||
|
||||
// Jika ada geojson, update geometri juga
|
||||
if (isset($_POST['geojson'])) {
|
||||
$geojson = $_POST['geojson'];
|
||||
$luas = floatval($_POST['luas'] ?? 0);
|
||||
$sql = "UPDATE parsil_tanah SET nama = ?, status = ?, geojson = ?, luas = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("sssdi", $nama, $status, $geojson, $luas, $id);
|
||||
} else {
|
||||
// Hanya update info
|
||||
$sql = "UPDATE parsil_tanah SET nama = ?, status = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("ssi", $nama, $status, $id);
|
||||
}
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,280 @@
|
||||
# 🗺️ WebGIS - Sistem Informasi SPBU Kota Pontianak
|
||||
|
||||
[](https://php.net)
|
||||
[](https://mysql.com)
|
||||
[](https://leafletjs.com)
|
||||
[](LICENSE)
|
||||
|
||||
Aplikasi WebGIS untuk mengelola dan memvisualisasikan data **SPBU**, **Jaringan Jalan**, dan **Parsil Tanah** di Kota Pontianak secara interaktif.
|
||||
|
||||
---
|
||||
|
||||
|
||||
## ✨ Fitur Utama
|
||||
|
||||
### 📍 Manajemen SPBU
|
||||
|
||||
* Tambah, edit, hapus data SPBU
|
||||
* Drag & drop marker untuk update posisi
|
||||
* Kategorisasi (24 jam / Tidak 24 jam)
|
||||
* Informasi kontak WhatsApp
|
||||
|
||||
### 🛣️ Manajemen Jalan
|
||||
|
||||
* Gambar polyline langsung di peta
|
||||
* Klasifikasi status jalan (Nasional/Provinsi/Kabupaten)
|
||||
* Hitung panjang jalan otomatis
|
||||
* Edit dan hapus data jalan
|
||||
|
||||
### 🏠 Manajemen Parsil Tanah
|
||||
|
||||
* Gambar polygon untuk bidang tanah
|
||||
* Klasifikasi status sertifikat (SHM/HGB/HGU/HP)
|
||||
* Hitung luas tanah otomatis
|
||||
* Edit dan hapus data parsil
|
||||
|
||||
### 🗺️ Fitur Peta
|
||||
|
||||
* Peta interaktif dengan Leaflet.js
|
||||
* Multiple layer control
|
||||
* Legend interaktif
|
||||
* Search dan filter data
|
||||
* Zoom to feature
|
||||
|
||||
### ⚙️ Layer Control & Tampilan
|
||||
|
||||
* **Layer Control Terpisah** - SPBU 24 jam dan Non 24 jam beda layer
|
||||
* **Tampilan Modern** - UI lebih elegan dengan font DM Sans
|
||||
* **Popup Koordinat** - Menampilkan latitude/longitude lengkap
|
||||
* **Loading State** - Animasi loading yang halus
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Teknologi yang Digunakan
|
||||
|
||||
| Teknologi | Kegunaan |
|
||||
| --------------------- | ------------------------------ |
|
||||
| PHP 7.4+ | Backend API & koneksi database |
|
||||
| MySQL | Database penyimpanan data |
|
||||
| Leaflet.js | Library peta interaktif |
|
||||
| Turf.js | Kalkulasi geometri |
|
||||
| Leaflet Draw | Drawing tools |
|
||||
| Leaflet Extra Markers | Marker kustom |
|
||||
| HTML5/CSS3/JS | Frontend |
|
||||
|
||||
---
|
||||
|
||||
## 📁 Struktur Folder
|
||||
|
||||
```
|
||||
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Instalasi
|
||||
|
||||
### Prasyarat
|
||||
|
||||
* XAMPP / Laragon / MAMP
|
||||
* PHP ≥ 7.4
|
||||
* MySQL ≥ 5.7
|
||||
* Browser modern
|
||||
|
||||
### Langkah Instalasi
|
||||
|
||||
#### 1. Clone Repository
|
||||
|
||||
```bash
|
||||
git clone https://github.com/username/SPBU.git
|
||||
```
|
||||
|
||||
#### 2. Pindahkan ke htdocs
|
||||
|
||||
```bash
|
||||
C:/xampp/htdocs/webgis/SPBU/
|
||||
```
|
||||
|
||||
#### 3. Import Database
|
||||
|
||||
**phpMyAdmin**
|
||||
|
||||
* http://localhost/phpmyadmin
|
||||
* Buat database: `webgis`
|
||||
* Import `webgis.sql`
|
||||
|
||||
**Command Line**
|
||||
|
||||
```bash
|
||||
mysql -u root -p
|
||||
CREATE DATABASE webgis;
|
||||
USE webgis;
|
||||
SOURCE webgis.sql;
|
||||
```
|
||||
|
||||
#### 4. Konfigurasi Database
|
||||
|
||||
```php
|
||||
<?php
|
||||
$host = 'localhost';
|
||||
$user = 'root';
|
||||
$password = '';
|
||||
$database = 'webgis';
|
||||
|
||||
$conn = new mysqli($host, $user, $password, $database);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['error' => true, 'message' => $conn->connect_error]));
|
||||
}
|
||||
?>
|
||||
```
|
||||
|
||||
#### 5. Jalankan Aplikasi
|
||||
|
||||
```
|
||||
http://localhost/webgis/01SPBU/
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📖 Cara Penggunaan
|
||||
|
||||
### Mode Navigasi
|
||||
|
||||
* Klik objek untuk melihat detail
|
||||
* Klik list untuk zoom lokasi
|
||||
|
||||
### Tambah SPBU
|
||||
|
||||
1. Klik tombol SPBU
|
||||
2. Klik peta
|
||||
3. Isi form
|
||||
4. Simpan
|
||||
|
||||
### Tambah Jalan
|
||||
|
||||
1. Klik Jalan
|
||||
2. Klik titik di peta
|
||||
3. Double click selesai
|
||||
4. Simpan
|
||||
|
||||
### Tambah Parsil
|
||||
|
||||
1. Klik Parsil
|
||||
2. Klik titik
|
||||
3. Selesaikan polygon
|
||||
4. Simpan
|
||||
|
||||
### Edit & Hapus
|
||||
|
||||
* Edit: tombol ✏️
|
||||
* Hapus: tombol 🗑️
|
||||
|
||||
---
|
||||
|
||||
## 🔧 API Endpoints
|
||||
|
||||
### SPBU
|
||||
|
||||
| Endpoint | Method |
|
||||
| -------------------------- | ------ |
|
||||
| /SPBU/ambil.php | GET |
|
||||
| /SPBU/simpan.php | POST |
|
||||
| /SPBU/hapus.php | POST |
|
||||
| /SPBU/update_lokasi.php | POST |
|
||||
| /SPBU/update_spbu_info.php | POST |
|
||||
|
||||
### Jalan
|
||||
|
||||
| Endpoint | Method |
|
||||
| ----------------------- | ------ |
|
||||
| /Jalan/ambil_jalan.php | GET |
|
||||
| /Jalan/simpan_jalan.php | POST |
|
||||
| /Jalan/hapus_jalan.php | POST |
|
||||
|
||||
### Parsil
|
||||
|
||||
| Endpoint | Method |
|
||||
| ------------------------- | ------ |
|
||||
| /Parsil/ambil_parsil.php | GET |
|
||||
| /Parsil/simpan_parsil.php | POST |
|
||||
| /Parsil/hapus_parsil.php | POST |
|
||||
|
||||
---
|
||||
|
||||
## 📊 Database Structure
|
||||
|
||||
### spbu
|
||||
|
||||
| Field | Type |
|
||||
| --------- | ------- |
|
||||
| id | INT |
|
||||
| nama | VARCHAR |
|
||||
| nomor | VARCHAR |
|
||||
| kategori | ENUM |
|
||||
| latitude | DECIMAL |
|
||||
| longitude | DECIMAL |
|
||||
|
||||
### jalan
|
||||
|
||||
| Field | Type |
|
||||
| ------- | -------- |
|
||||
| id | INT |
|
||||
| nama | VARCHAR |
|
||||
| status | VARCHAR |
|
||||
| panjang | DOUBLE |
|
||||
| geojson | LONGTEXT |
|
||||
|
||||
### parsil_tanah
|
||||
|
||||
| Field | Type |
|
||||
| ------- | -------- |
|
||||
| id | INT |
|
||||
| nama | VARCHAR |
|
||||
| status | VARCHAR |
|
||||
| luas | DOUBLE |
|
||||
| geojson | LONGTEXT |
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Troubleshooting
|
||||
|
||||
**Data tidak muncul**
|
||||
|
||||
```php
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
```
|
||||
|
||||
**Path error**
|
||||
|
||||
* Gunakan `__DIR__`
|
||||
|
||||
**Peta tidak muncul**
|
||||
|
||||
* Cek internet & console
|
||||
|
||||
**Data gagal simpan**
|
||||
|
||||
* Cek DB & permission
|
||||
|
||||
---
|
||||
|
||||
## 👥 Kontributor
|
||||
|
||||
* Cindy Dyra Islamay — Fullstack Developer
|
||||
|
||||
---
|
||||
|
||||
## 📝 Lisensi
|
||||
|
||||
MIT License
|
||||
|
||||
---
|
||||
|
||||
## 📞 Kontak
|
||||
|
||||
* Email: [d1041231045@student.untan.ac.id]
|
||||
|
||||
---
|
||||
|
||||
⭐ Jika project ini membantu, beri bintang di repository.
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
// Cek koneksi
|
||||
if (!isset($conn) || $conn->connect_error) {
|
||||
throw new Exception("Database connection failed");
|
||||
}
|
||||
|
||||
$result = $conn->query("SELECT * FROM spbu ORDER BY created_at DESC");
|
||||
|
||||
if (!$result) {
|
||||
throw new Exception("Query failed: " . $conn->error);
|
||||
}
|
||||
|
||||
$data = array();
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$data[] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($data);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'error' => true,
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($conn)) {
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'ID tidak valid']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM spbu WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("i", $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Data SPBU berhasil dihapus']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
throw new Exception('Invalid request method');
|
||||
}
|
||||
|
||||
$nama = isset($_POST['nama']) ? trim($_POST['nama']) : '';
|
||||
$nomor = isset($_POST['nomor']) ? trim($_POST['nomor']) : '';
|
||||
$kategori = isset($_POST['kategori']) ? trim($_POST['kategori']) : '';
|
||||
$lat = isset($_POST['latitude']) ? floatval($_POST['latitude']) : null;
|
||||
$lng = isset($_POST['longitude']) ? floatval($_POST['longitude']) : null;
|
||||
|
||||
if (empty($nama) || empty($nomor) || empty($kategori)) {
|
||||
throw new Exception('Semua field harus diisi');
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO spbu (nama, nomor, kategori, latitude, longitude) VALUES (?, ?, ?, ?, ?)";
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
||||
if (!$stmt) {
|
||||
throw new Exception('Prepare failed: ' . $conn->error);
|
||||
}
|
||||
|
||||
$stmt->bind_param("sssdd", $nama, $nomor, $kategori, $lat, $lng);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode([
|
||||
'status' => 'success',
|
||||
'message' => 'Data berhasil disimpan',
|
||||
'id' => $conn->insert_id
|
||||
]);
|
||||
} else {
|
||||
throw new Exception('Execute failed: ' . $stmt->error);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
if (isset($conn)) {
|
||||
$conn->close();
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request method']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$latitude = floatval($_POST['latitude'] ?? 0);
|
||||
$longitude = floatval($_POST['longitude'] ?? 0);
|
||||
|
||||
if ($id <= 0) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'ID tidak valid']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE spbu SET latitude = ?, longitude = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
|
||||
if (!$stmt) {
|
||||
echo json_encode(['status' => 'error', 'message' => $conn->error]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$stmt->bind_param("ddi", $latitude, $longitude, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Lokasi diupdate']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require_once __DIR__ . '/../koneksi.php';
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Invalid request']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$id = intval($_POST['id'] ?? 0);
|
||||
$nama = trim($_POST['nama'] ?? '');
|
||||
$nomor = trim($_POST['nomor'] ?? '');
|
||||
$kategori = trim($_POST['kategori'] ?? '');
|
||||
|
||||
if ($id <= 0 || empty($nama) || empty($nomor) || empty($kategori)) {
|
||||
echo json_encode(['status' => 'error', 'message' => 'Data tidak lengkap']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$sql = "UPDATE spbu SET nama = ?, nomor = ?, kategori = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($sql);
|
||||
$stmt->bind_param("sssi", $nama, $nomor, $kategori, $id);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['status' => 'success', 'message' => 'Data SPBU diupdate']);
|
||||
} else {
|
||||
echo json_encode(['status' => 'error', 'message' => $stmt->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
$conn->close();
|
||||
?>
|
||||
@@ -0,0 +1,198 @@
|
||||
-- phpMyAdmin SQL Dump
|
||||
-- version 5.2.1
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Host: 127.0.0.1
|
||||
-- Generation Time: Jun 07, 2026 at 07:10 PM
|
||||
-- Server version: 10.4.32-MariaDB
|
||||
-- PHP Version: 8.2.12
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Database: `webgis`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `jalan`
|
||||
--
|
||||
|
||||
CREATE TABLE `jalan` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(255) NOT NULL COMMENT 'Nama ruas jalan',
|
||||
`status` varchar(100) NOT NULL COMMENT 'Status jalan (e.g. Nasional, Provinsi, Kabupaten, Desa)',
|
||||
`panjang` double NOT NULL DEFAULT 0 COMMENT 'Panjang jalan dalam meter',
|
||||
`geojson` longtext NOT NULL COMMENT 'Geometri jalan dalam format GeoJSON',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Data segmen jalan (polyline) dalam format GeoJSON';
|
||||
|
||||
--
|
||||
-- Dumping data for table `jalan`
|
||||
--
|
||||
|
||||
INSERT INTO `jalan` (`id`, `nama`, `status`, `panjang`, `geojson`, `created_at`) VALUES
|
||||
(1, 'Jalan Sepakat 2', 'Kabupaten', 1784.791473379715, '{\"type\":\"Feature\",\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[109.35178399086,-0.0583629161931721],[109.35063600540163,-0.05999276433692213],[109.34970259666444,-0.06140815873824388],[109.3490481376648,-0.062394645723090975],[109.34783577919008,-0.06381004006026729],[109.34582948684694,-0.06598674491163233],[109.3437159061432,-0.06820159083180335],[109.34262156486513,-0.06938108597800444],[109.34150576591493,-0.07064203975056207],[109.34150576591493,-0.07064203975056207],[109.34150576591493,-0.07064203975056207]]},\"properties\":{}}', '2026-06-07 16:09:11');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `parsil_tanah`
|
||||
--
|
||||
|
||||
CREATE TABLE `parsil_tanah` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(255) NOT NULL COMMENT 'Nama parsil / bidang tanah',
|
||||
`status` varchar(50) NOT NULL COMMENT 'Status hak (SHM | HGB | HGU | HP)',
|
||||
`luas` double NOT NULL DEFAULT 0 COMMENT 'Luas area dalam meter persegi',
|
||||
`geojson` longtext NOT NULL COMMENT 'Geometri parsil dalam format GeoJSON',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Data parsil tanah (polygon) dalam format GeoJSON';
|
||||
|
||||
--
|
||||
-- Dumping data for table `parsil_tanah`
|
||||
--
|
||||
|
||||
INSERT INTO `parsil_tanah` (`id`, `nama`, `status`, `luas`, `geojson`, `created_at`) VALUES
|
||||
(1, 'Pengadilan Tinggi Negeri', 'HGB', 1312.2666173966293, '{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[109.35532987117769,-0.06302106891085976],[109.35539424419404,-0.06308540501714478],[109.35543715953828,-0.06303715293742466],[109.35552835464479,-0.06313365709682675],[109.35549080371857,-0.06317654783426951],[109.35555517673494,-0.06327841333559274],[109.35537278652193,-0.06346069896896436],[109.35512065887453,-0.06321407722949855],[109.3551367521286,-0.06319263186079624],[109.3551367521286,-0.06319263186079624],[109.35532987117769,-0.06302106891085976]]]},\"properties\":{}}', '2026-06-07 16:02:58'),
|
||||
(2, 'Hutan Sylva UNTAN', 'HP', 31066.903716160716, '{\"type\":\"Feature\",\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[109.34868872165681,-0.05657792397283722],[109.34927880764009,-0.05576299985790386],[109.3494075536728,-0.055827335972649154],[109.34962749481203,-0.055784445229494106],[109.35099005699159,-0.0574571841892975],[109.35042142868042,-0.05825066290960069],[109.34964895248415,-0.05740893210459027],[109.34938609600069,-0.057092612881665034],[109.34924125671388,-0.05700147005438797],[109.34868872165681,-0.05657792397283722]]]},\"properties\":{}}', '2026-06-07 17:07:13');
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `polygons`
|
||||
--
|
||||
|
||||
CREATE TABLE `polygons` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(255) NOT NULL COMMENT 'Nama polygon',
|
||||
`coordinates` longtext NOT NULL COMMENT 'Koordinat polygon (JSON string)',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Layer polygon generik (koordinat sebagai teks JSON)';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `polylines`
|
||||
--
|
||||
|
||||
CREATE TABLE `polylines` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(255) NOT NULL COMMENT 'Nama polyline',
|
||||
`coordinates` longtext NOT NULL COMMENT 'Koordinat polyline (JSON string)',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Layer polyline generik (koordinat sebagai teks JSON)';
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `spbu`
|
||||
--
|
||||
|
||||
CREATE TABLE `spbu` (
|
||||
`id` int(11) NOT NULL,
|
||||
`nama` varchar(255) NOT NULL COMMENT 'Nama SPBU',
|
||||
`nomor` varchar(100) NOT NULL COMMENT 'Nomor WhatsApp / kontak',
|
||||
`kategori` varchar(50) NOT NULL COMMENT '24_jam | tidak_24_jam',
|
||||
`latitude` decimal(10,8) DEFAULT NULL COMMENT 'Koordinat lintang',
|
||||
`longitude` decimal(11,8) DEFAULT NULL COMMENT 'Koordinat bujur',
|
||||
`created_at` timestamp NOT NULL DEFAULT current_timestamp()
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Data titik lokasi SPBU';
|
||||
|
||||
--
|
||||
-- Dumping data for table `spbu`
|
||||
--
|
||||
|
||||
INSERT INTO `spbu` (`id`, `nama`, `nomor`, `kategori`, `latitude`, `longitude`, `created_at`) VALUES
|
||||
(1, 'SPBU Parit Husein', '0824245345', 'tidak', -0.06431884, 109.35623646, '2026-06-07 16:02:20'),
|
||||
(2, 'SPBU Kota Baru', '085154545', '24_jam', -0.04773790, 109.31863725, '2026-06-07 17:10:26');
|
||||
|
||||
--
|
||||
-- Indexes for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- Indexes for table `jalan`
|
||||
--
|
||||
ALTER TABLE `jalan`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `idx_jalan_status` (`status`),
|
||||
ADD KEY `idx_jalan_created_at` (`created_at`);
|
||||
|
||||
--
|
||||
-- Indexes for table `parsil_tanah`
|
||||
--
|
||||
ALTER TABLE `parsil_tanah`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `idx_parsil_status` (`status`),
|
||||
ADD KEY `idx_parsil_created_at` (`created_at`);
|
||||
|
||||
--
|
||||
-- Indexes for table `polygons`
|
||||
--
|
||||
ALTER TABLE `polygons`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `idx_polygons_created_at` (`created_at`);
|
||||
|
||||
--
|
||||
-- Indexes for table `polylines`
|
||||
--
|
||||
ALTER TABLE `polylines`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `idx_polylines_created_at` (`created_at`);
|
||||
|
||||
--
|
||||
-- Indexes for table `spbu`
|
||||
--
|
||||
ALTER TABLE `spbu`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `idx_spbu_kategori` (`kategori`),
|
||||
ADD KEY `idx_spbu_created_at` (`created_at`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `jalan`
|
||||
--
|
||||
ALTER TABLE `jalan`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `parsil_tanah`
|
||||
--
|
||||
ALTER TABLE `parsil_tanah`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `polygons`
|
||||
--
|
||||
ALTER TABLE `polygons`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `polylines`
|
||||
--
|
||||
ALTER TABLE `polylines`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `spbu`
|
||||
--
|
||||
ALTER TABLE `spbu`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
+1793
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
// Set header JSON untuk semua response
|
||||
header('Content-Type: application/json');
|
||||
|
||||
$host = 'localhost';
|
||||
$user = 'root';
|
||||
$password = ''; // Pastikan password MySQL Anda
|
||||
$database = 'webgis';
|
||||
|
||||
try {
|
||||
// Buat koneksi
|
||||
$conn = new mysqli($host, $user, $password, $database);
|
||||
|
||||
// Cek koneksi
|
||||
if ($conn->connect_error) {
|
||||
throw new Exception("Koneksi gagal: " . $conn->connect_error);
|
||||
}
|
||||
|
||||
// Set charset
|
||||
$conn->set_charset("utf8");
|
||||
|
||||
} catch (Exception $e) {
|
||||
// Jika error, tetap kembalikan JSON
|
||||
echo json_encode([
|
||||
'status' => 'error',
|
||||
'message' => $e->getMessage()
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user