Skip to content

Commit

Permalink
feature/geolocation: GEO location support has been implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
pipisco committed Jun 23, 2024
1 parent 89e9713 commit d4fa2b1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Facades/DaDataAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

/**
* @method static suggest(string[] $array)
* @method static geoLocate(string[] $array)
*/
class DaDataAddress extends Facade
{
Expand Down
8 changes: 8 additions & 0 deletions src/Http/Router.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,4 +132,12 @@ public static function cleanAddress(): string
return 'clean/address';
}

/**
* @return string
*/
public static function geoLocateAddress(): string
{
return 'rs/geolocate/address';
}

}
47 changes: 47 additions & 0 deletions src/Methods/Address/GeoLocateMethod.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace MoveMoveApp\DaData2\Methods\Address;

use GuzzleHttp\Client;
use MoveMoveApp\DaData2\Http\Router;
use MoveMoveApp\DaData2\Methods\BaseMethod;

/**
* Reverse geocoding
*
* Reverse geocoding (address by coordinates) has been implemented to find the nearest addresses (houses, streets, cities) based on geographic coordinates.
*
* @note: This service is available exclusively for Russia.
*
* @link https://dadata.ru/api/geolocate/
*
* @property string $lat
* @property string $lon
* @property string $count
* @property string $radius_meters
* @property array $language
*/
class GeoLocateMethod extends BaseMethod
{
protected string $method = 'POST';
protected string $entryPoint;
protected string $expect = 'Address';
protected array $parameters = [
'lat' => 'float',
'lon' => 'float',
'count' => 'integer',
'radius_meters' => 'integer',
'language' => 'string',
];

/**
* @param Client $client
*
*/
public function __construct(Client &$client)
{
$this->entryPoint = Router::geoLocateAddress();

parent::__construct($client);
}
}

0 comments on commit d4fa2b1

Please sign in to comment.