CoolCMS API

GeocodingCacheKey
in package

FinalYes

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

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
self

fromAddress()

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|null

getStoredQuery()

Returns the stored form of the query (cut to the column width; the hash stays from the whole address).

public getStoredQuery() : string
Return values
string

normalizeAddress()

public static normalizeAddress(string $address) : string
Parameters
$address : string
Return values
string

normalizeCountryCode()

"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
On this page

Search results