Pembaruan pertama: Implementasi WebGIS CRUD dan Layer SPBU
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
require 'koneksi.php';
|
||||
|
||||
$data = json_decode(file_get_contents("php://input"), true);
|
||||
|
||||
if (!$data) {
|
||||
echo json_encode(["status" => "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()]);
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user