asdas
This commit is contained in:
@@ -197,8 +197,12 @@ final class AccountPages
|
|||||||
$region = trim((string)($_POST['region'] ?? ''));
|
$region = trim((string)($_POST['region'] ?? ''));
|
||||||
$lat = isset($_POST['lat']) && $_POST['lat'] !== '' ? (float)$_POST['lat'] : null;
|
$lat = isset($_POST['lat']) && $_POST['lat'] !== '' ? (float)$_POST['lat'] : null;
|
||||||
$lng = isset($_POST['lng']) && $_POST['lng'] !== '' ? (float)$_POST['lng'] : null;
|
$lng = isset($_POST['lng']) && $_POST['lng'] !== '' ? (float)$_POST['lng'] : null;
|
||||||
if ($lat === null || $lng === null) {
|
$needsGeocode = ($lat === null || $lng === null || $region === '');
|
||||||
[$lat, $lng] = self::geocodeAddress($street, $zip, $city, $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') {
|
if ($action === 'event_add') {
|
||||||
@@ -352,7 +356,7 @@ final class AccountPages
|
|||||||
$region ?: null,
|
$region ?: null,
|
||||||
]);
|
]);
|
||||||
if (!$parts) {
|
if (!$parts) {
|
||||||
return [null, null];
|
return [null, null, null];
|
||||||
}
|
}
|
||||||
|
|
||||||
$query = implode(', ', $parts);
|
$query = implode(', ', $parts);
|
||||||
@@ -372,12 +376,14 @@ final class AccountPages
|
|||||||
|
|
||||||
$resp = @file_get_contents($url, false, $ctx);
|
$resp = @file_get_contents($url, false, $ctx);
|
||||||
if ($resp === false) {
|
if ($resp === false) {
|
||||||
return [null, null];
|
return [null, null, null];
|
||||||
}
|
}
|
||||||
$json = json_decode($resp, true);
|
$json = json_decode($resp, true);
|
||||||
if (!is_array($json) || empty($json[0]['lat']) || empty($json[0]['lon'])) {
|
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user