Files
2026-05-12 10:16:16 +07:00

30 lines
762 B
PHP

<?php
header('Content-Type: application/json');
include __DIR__ . '/../db_config.php';
$sql = "SELECT id, nama_objek, kategori, status_objek, type, geometry_data, nilai_ukur, created_at
FROM spatial_features
ORDER BY created_at DESC";
$result = $conn->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()) {
$row['geometry_data'] = json_decode($row['geometry_data']);
$row['nilai_ukur'] = (float)$row['nilai_ukur'];
$features[] = $row;
}
}
echo json_encode($features);
$conn->close();
?>