GeocodingCacheKey
in package
Key of a `cms_system_geocoding_cache` row: `query_hash = sha1(country | normalized address)`, unique.
Normalization: no diacritics, lowercase, unified spaces and commas, postcode without a space ("Main St 1, 288 02 Nymburk" = "main st 1,28802 nymburk"). The same query is recognized under a different spelling, so Google is not paid for twice.
Table of Contents
Constants
- QUERY_MAX_LENGTH : int = 500
- Length of `cms_system_geocoding_cache.query` (varchar 500); the hash is computed from the whole address.
Properties
- $countryCode : string
- $hash : string
- $query : string
Methods
- externalErrorBreaker() : self
- Fixed key of the sentinel row "external geocoder is failing now" (quota exhausted, network).
- fromAddress() : self|null
- Returns `null` when nothing is left after normalization (nothing to cache or send to Google).
- getStoredQuery() : string
- Returns the stored form of the query (cut to the column width; the hash stays from the whole address).
- normalizeAddress() : string
- normalizeCountryCode() : string
- "cz" -> "CZ"; anything other than two letters -> empty string (unknown country).
- __construct() : mixed
Constants
QUERY_MAX_LENGTH
Length of `cms_system_geocoding_cache.query` (varchar 500); the hash is computed from the whole address.
public
int
QUERY_MAX_LENGTH
= 500
Properties
$countryCode read-only
public
string
$countryCode
$hash read-only
public
string
$hash
$query read-only
public
string
$query
Methods
externalErrorBreaker()
Fixed key of the sentinel row "external geocoder is failing now" (quota exhausted, network).
public
static externalErrorBreaker() : self
Needs no schema change: a row with status error is valid only briefly
(GeocodingCacheEntry::ERROR_RETRY_MINUTES). Its hash cannot collide with an
address hash because it is not built from the country|address shape.
Return values
selffromAddress()
Returns `null` when nothing is left after normalization (nothing to cache or send to Google).
public
static fromAddress(string $countryCode, string $address) : self|null
Parameters
- $countryCode : string
- $address : string
Return values
self|nullgetStoredQuery()
Returns the stored form of the query (cut to the column width; the hash stays from the whole address).
public
getStoredQuery() : string
Return values
stringnormalizeAddress()
public
static normalizeAddress(string $address) : string
Parameters
- $address : string
Return values
stringnormalizeCountryCode()
"cz" -> "CZ"; anything other than two letters -> empty string (unknown country).
public
static normalizeCountryCode(string $countryCode) : string
Parameters
- $countryCode : string
Return values
string__construct()
private
__construct(string $countryCode, string $query, string $hash) : mixed
Parameters
- $countryCode : string
- $query : string
- $hash : string