This commit is contained in:
2026-01-03 02:08:46 +01:00
parent a7f6af65af
commit 6d6f18c471

View File

@@ -197,8 +197,12 @@ final class AccountPages
$region = trim((string)($_POST['region'] ?? ''));
$lat = isset($_POST['lat']) && $_POST['lat'] !== '' ? (float)$_POST['lat'] : null;
$lng = isset($_POST['lng']) && $_POST['lng'] !== '' ? (float)$_POST['lng'] : null;
if ($lat === null || $lng === null) {
[$lat, $lng] = self::geocodeAddress($street, $zip, $city, $region);
$needsGeocode = ($lat === null || $lng === null || $region === '');
if ($needsGeocode) {
[$geoLat, $geoLng, $geoRegion] = self::geocodeAddress($street, $zip, $city, $region);
if ($lat === null) { $lat = $geoLat; }
if ($lng === null) { $lng = $geoLng; }
if ($region === '' && $geoRegion) { $region = $geoRegion; }
}
if ($action === 'event_add') {
@@ -352,7 +356,7 @@ final class AccountPages
$region ?: null,
]);
if (!$parts) {
return [null, null];
return [null, null, null];
}
$query = implode(', ', $parts);
@@ -372,12 +376,14 @@ final class AccountPages
$resp = @file_get_contents($url, false, $ctx);
if ($resp === false) {
return [null, null];
return [null, null, null];
}
$json = json_decode($resp, true);
if (!is_array($json) || empty($json[0]['lat']) || empty($json[0]['lon'])) {
return [null, null];
return [null, null, null];
}
return [round((float)$json[0]['lat'], 7), round((float)$json[0]['lon'], 7)];
$addr = $json[0]['address'] ?? [];
$regionGuess = $addr['city_district'] ?? $addr['suburb'] ?? $addr['state'] ?? $addr['county'] ?? $addr['region'] ?? $addr['state_district'] ?? null;
return [round((float)$json[0]['lat'], 7), round((float)$json[0]['lon'], 7), $regionGuess];
}
}