Files
2026-06-13 13:38:52 +07:00

33 lines
807 B
PHP

<?php
include 'db.php';
$features = [];
// Ambil semua data
$result = $conn->query("SELECT * FROM data_unified");
while($row = $result->fetch_assoc()){
if($row['tipe'] == 'jalan' || $row['tipe'] == 'parsil'){
$geom_json = $row['geom'];
$geom = json_decode($geom_json, true);
if ($geom === null) {
error_log("Invalid JSON in geom for id " . $row['id'] . ": " . $geom_json);
continue;
}
$geom['properties'] = [
"id" => $row['id'],
"tipe" => $row['tipe'],
"status" => $row['status'],
"nilai" => $row['tipe'] == 'jalan' ? $row['panjang'] : $row['luas']
];
$features[] = $geom;
}
}
echo json_encode([
"type" => "FeatureCollection",
"features" => $features
]);
?>