First commit / commit pertama
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/**
|
||||
* api/heatmap.php — Titik kepadatan kemiskinan agregat (KF-08).
|
||||
*
|
||||
* GET → daftar [lat, lng, weight] tanpa data pribadi (aman untuk publik).
|
||||
* weight = jumlah_tanggungan + 1 (intensitas kepadatan).
|
||||
*/
|
||||
require_once __DIR__ . '/../config/db.php';
|
||||
require_once __DIR__ . '/helpers.php';
|
||||
|
||||
$pdo = Database::getConnection();
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] !== 'GET') {
|
||||
sendError('Method not allowed', 405);
|
||||
}
|
||||
|
||||
$stmt = $pdo->query(
|
||||
"SELECT ST_Y(geom) AS lat, ST_X(geom) AS lng, jumlah_tanggungan
|
||||
FROM warga_miskin"
|
||||
);
|
||||
|
||||
$points = [];
|
||||
while ($r = $stmt->fetch()) {
|
||||
$points[] = [
|
||||
(float)$r['lat'],
|
||||
(float)$r['lng'],
|
||||
(int)$r['jumlah_tanggungan'] + 1,
|
||||
];
|
||||
}
|
||||
|
||||
sendSuccess($points, 'Heatmap Kepadatan');
|
||||
Reference in New Issue
Block a user