• Модуль: location
  • Путь к файлу: ~/bitrix/modules/location/lib/source/osm/converters/baseconverter.php
  • Класс: BitrixLocationSourceOsmConvertersBaseConverter
  • Вызов: BaseConverter::getCountry
private function getCountry(): ?array
{
	/**
	 * Case #1 (country itself)
	 * @see https://github.com/osm-search/Nominatim/issues/1806
	 * @see https://nominatim.openstreetmap.org/ui/details.html?osmtype=R&osmid=60189
	 * @see https://nominatim.openstreetmap.org/details?osmtype=R&osmid=60189&addressdetails=1&linkedplaces=0&format=json
	 *
	 */
	foreach ($this->addressComponents as $addressComponent)
	{
		if ($addressComponent['class'] === 'boundary'
			&& $addressComponent['type'] === 'administrative'
			&& $addressComponent['admin_level'] === static::COUNTRY_ADMIN_LEVEL
		)
		{
			return $addressComponent;
		}
	}

	/**
	 * Case #2 (item within a country)
	 * @see https://github.com/osm-search/Nominatim/issues/1806
	 * @see https://nominatim.openstreetmap.org/ui/details.html?osmtype=R&osmid=1674442
	 * @see https://nominatim.openstreetmap.org/details?osmtype=R&osmid=1674442&addressdetails=1&linkedplaces=0&format=json
	 *
	 */
	foreach ($this->addressComponents as $addressComponent)
	{
		if ($addressComponent['class'] === 'place' && $addressComponent['type'] === 'country')
		{
			return $addressComponent;
		}
	}

	return null;
}