<?php
declare(strict_types=1);

require_once __DIR__ . '/db_pdo.php';
require_once __DIR__ . '/spatial_helpers.php';

$input = get_json_input();
$id = (int) ($input['id'] ?? 0);

if ($id <= 0) {
    json_response(422, [
        'success' => false,
        'message' => 'ID parsil tidak valid.',
    ]);
}

$stmt = $pdo->prepare('DELETE FROM parsil_tanah WHERE id = :id');
$stmt->execute([':id' => $id]);

if ($stmt->rowCount() < 1) {
    json_response(404, [
        'success' => false,
        'message' => 'Data parsil tidak ditemukan.',
    ]);
}

json_response(200, [
    'success' => true,
    'message' => 'Data parsil tanah berhasil dihapus.',
]);
