Skip to content

Commit 80ea930

Browse files
authored
Merge pull request #10 from botgun/feat/9-address-find-by-id
feat: add support for address lookup by FIAS, KLADR, cadastral or Geo…
2 parents 4070b77 + e17caa9 commit 80ea930

File tree

4 files changed

+99
-1
lines changed

4 files changed

+99
-1
lines changed

src/Facades/DaDataAddress.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* @method static suggest(string[] $array)
99
* @method static geoLocate(string[] $array)
1010
* @method static suggestPostal(string[] $array)
11+
* @method static findById(string[] $array)
1112
*/
1213
class DaDataAddress extends Facade
1314
{

src/Http/Router.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,12 @@ public static function geoLocateAddress(): string
156156
return 'rs/geolocate/address';
157157
}
158158

159+
/**
160+
* @return string
161+
*/
162+
public static function findByIdAddress(): string
163+
{
164+
return 'rs/findById/address';
165+
}
166+
159167
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?php
2+
3+
namespace BotGun\DaData\Methods\Address;
4+
5+
use GuzzleHttp\Client;
6+
use BotGun\DaData\Http\Router;
7+
use BotGun\DaData\Methods\BaseMethod;
8+
9+
/**
10+
* Find address by FIAS, GAR, KLADR code or cadastral number
11+
*
12+
* Searches for addresses using any part of the address, from region to apartment ("piter zelenkov 7a" → "194044,
13+
* Business Center 'Chagall', Zelenkov Lane, 7a lit Z, office 16"). It also searches by postal code ("194044" → "St.
14+
* Petersburg, Zelenkov Lane").
15+
* Capabilities:
16+
* - Global Coverage: Works for all countries worldwide. In Russia, it provides detailed addresses down to the
17+
* apartment level; in Belarus, Kazakhstan, and Uzbekistan,
18+
* it provides addresses down to the house level; for other countries, it provides addresses down to the city
19+
* level. It searches and displays results in both. Russian ("Самара, пр-кт Металлургов") and English ("Russia,
20+
* gorod Samara, prospekt Metallurgov").
21+
* - Historical and Synonym Search: Finds current addresses using historical names (e.g., "Свердловск" →
22+
* "Екатеринбург") and synonyms
23+
* (e.g., "Питер" → "Санкт-Петербург").
24+
* - Partial Matching: Searches using partial matches for the last word in the query ("москва болот" → "г Москва,
25+
* Болотная наб"), but not for the initial words ("мос болот" will not find it).
26+
* - Error Correction: Corrects typos (e.g., "самара авиционная") and queries typed in the wrong keyboard layout
27+
* (e.g., "vjcrdf" → "москва").
28+
* - Cadastral and FIAS Codes: Finds addresses using cadastral numbers ("77:02:0004008:4143") and FIAS codes
29+
* ("f26b876b-6857-4951-b060-ec6559f04a9a").
30+
* - Detailed Breakdown: Returns addresses in administrative and municipal divisions, breaking down the selected
31+
* address into granular parts (from region to apartment).
32+
* - Granular Suggest: Provides granular suggestions for specific parts of the address (regions, cities,
33+
* streets, houses).
34+
* - Land Parcels: Identifies land parcels ("казань красная участок 109в" → "420025, Респ Татарстан, г Казань,
35+
* Советский р-н, ул Большая Красная (Малые Клыки), уч 109в").
36+
* - Location Awareness: Takes into account your location (in conjunction with the method for determining the city
37+
* by IP address).
38+
* Limitations:
39+
* - Automated Processing: Cannot automatically (without human intervention) process addresses from a database
40+
* or file.
41+
* - Transliteration: Does not transliterate addresses (e.g., "moskva suhonskaja 11" → "127642, г Москва, ул
42+
* Сухонская, д 11").
43+
*
44+
* @note: FIAS codes for buildings and apartments may change over time. To ensure data integrity, we recommend saving
45+
* the full address as a plain string in addition to the FIAS code. This will help preserve the address even if the
46+
* official code changes.
47+
*
48+
*
49+
* @link https://dadata.ru/api/find-address/
50+
*
51+
* @property string $query
52+
* @property string $count
53+
* @property string $language
54+
* @property string $division
55+
* @property array $locations
56+
* @property string $locations_geo
57+
* @property string $locations_boost
58+
* @property string $from_bound
59+
* @property string $to_bound
60+
*/
61+
class FindByIdMethod extends BaseMethod
62+
{
63+
protected string $method = 'POST';
64+
protected string $entryPoint;
65+
protected string $expect = 'Address';
66+
protected array $parameters = [
67+
'query' => 'string',
68+
'count' => 'integer',
69+
'language' => 'string',
70+
'division' => 'string',
71+
'locations' => 'array',
72+
'locations_geo' => 'string',
73+
'locations_boost' => 'string',
74+
'from_bound' => 'string',
75+
'to_bound' => 'string',
76+
];
77+
78+
/**
79+
* @param Client $client
80+
*
81+
*/
82+
public function __construct(Client &$client)
83+
{
84+
$this->entryPoint = Router::suggestAddress();
85+
86+
parent::__construct($client);
87+
}
88+
}

src/Methods/Address/GeoLocateMethod.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
/**
1010
* Reverse geocoding
1111
*
12-
* Reverse geocoding (address by coordinates) has been implemented to find the nearest addresses (houses, streets, cities) based on geographic coordinates.
12+
* Reverse geocoding (address by coordinates) has been implemented to find the nearest addresses (houses, streets,
13+
* cities) based on geographic coordinates.
1314
*
1415
* @note: This service is available exclusively for Russia.
1516
*

0 commit comments

Comments
 (0)