CoolCMS API

GeocodingManager
in package

FinalYes

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:

  1. 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 _r is stale (without JS the hidden value from the URL is sent again with a different text);
  2. 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;
  3. 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

$regionManager  : RegionManager

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

Properties

Methods

textMatchesRegionName()

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

Search results