Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?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
|
||||
]);
|
||||
?>
|
||||
Reference in New Issue
Block a user