GeocodingManager
in package
Point for the "within X km of" filter, the single place for the Bazaar and Comcat lists (`Core\Traits\Front\Presenters\AddressDistanceFilterTrait`).
Sources of the point, in order:
p[<id>_r]: the region chosen in the suggester gives its center (region/district/ municipality; the average of municipalities without own coordinates). Only while the URL text still matches the region name, otherwise_ris stale (without JS the hidden value from the URL is sent again with a different text);- free text found in the dataset via the Api suggest: an exact match of the name (municipality, district, region) or of the whole postcode; a prefix is not enough, it would be a guess;
cms_system_geocoding_cache, then Google, then a cache write (resolveExternal()), all in the Api (:Api:System:Region:geocode); the front end touches neither the cache nor Google.
null = no point, so the caller filters by text match. When the suggest is rate limited
(60/min/IP), Google is not called: repeated requests over the limit are rather a robot and
Google is paid.
Manager tier: composes RegionManager (via the Api), has no lower layers of its own.
Table of Contents
Constants
- DATASET_LIMIT : int = 5
- An exact match is always in the first suggest sort group (rank 0), so no more items are needed.
- MIN_LEVEL : int = 2
- The filter may use a region or district too (decision: outside an advert a higher level is allowed).
- POSTCODE_LENGTH : int = 5
Properties
Methods
- __construct() : mixed
- pickExactMatch() : RegionSuggestItem|null
- First suggest item that is an exact match of the query: the whole postcode (5 digits) or the node name (ASCII, case-insensitive). The item order comes from the Api (localization country, weight).
- resolveSearchPoint() : GeocodingResult|null
- textMatchesRegionName() : bool
- Does the URL text match the region name? Compared in ASCII, case-insensitively, and it is enough that the text contains the name: after a pick the field holds a label (postcode plus city, or "City (District, Region)"), not the bare name.
- resolveDatasetMatch() : GeocodingResult|null
- resolveExternal() : GeocodingResult|null
- Cache, then Google, then a cache write (Api); `null` = not found or Google unavailable.
- resolveSelectedRegion() : GeocodingResult|null
Constants
DATASET_LIMIT
An exact match is always in the first suggest sort group (rank 0), so no more items are needed.
private
int
DATASET_LIMIT
= 5
MIN_LEVEL
The filter may use a region or district too (decision: outside an advert a higher level is allowed).
private
int
MIN_LEVEL
= 2
POSTCODE_LENGTH
private
int
POSTCODE_LENGTH
= 5
Properties
$regionManager read-only
private
RegionManager
$regionManager
Methods
__construct()
public
__construct(RegionManager $regionManager) : mixed
Parameters
- $regionManager : RegionManager
pickExactMatch()
First suggest item that is an exact match of the query: the whole postcode (5 digits) or the node name (ASCII, case-insensitive). The item order comes from the Api (localization country, weight).
public
static pickExactMatch(RegionSuggestQuery $query, array<int, RegionSuggestItem> $items) : RegionSuggestItem|null
Parameters
- $query : RegionSuggestQuery
- $items : array<int, RegionSuggestItem>
Return values
RegionSuggestItem|nullresolveSearchPoint()
public
resolveSearchPoint(GeocodingSearchRequest $request) : GeocodingResult|null
Parameters
- $request : GeocodingSearchRequest
Return values
GeocodingResult|nulltextMatchesRegionName()
Does the URL text match the region name? Compared in ASCII, case-insensitively, and it is enough that the text contains the name: after a pick the field holds a label (postcode plus city, or "City (District, Region)"), not the bare name.
public
static textMatchesRegionName(string $text, string $name) : bool
Parameters
- $text : string
- $name : string
Return values
boolresolveDatasetMatch()
private
resolveDatasetMatch(RegionSuggestQuery $query, array<int, RegionSuggestItem> $items, int $languageId) : GeocodingResult|null
Parameters
- $query : RegionSuggestQuery
- $items : array<int, RegionSuggestItem>
- $languageId : int
Return values
GeocodingResult|nullresolveExternal()
Cache, then Google, then a cache write (Api); `null` = not found or Google unavailable.
private
resolveExternal(string $text, GeocodingSearchRequest $request) : GeocodingResult|null
Parameters
- $text : string
- $request : GeocodingSearchRequest
Return values
GeocodingResult|nullresolveSelectedRegion()
private
resolveSelectedRegion(GeocodingSearchRequest $request, string $text) : GeocodingResult|null
Parameters
- $request : GeocodingSearchRequest
- $text : string